Skip to content

Commit 41f322c

Browse files
committed
Updated static object structure
Now creating global objects work properly Small changes in define options
1 parent aa6e531 commit 41f322c

File tree

9 files changed

+23
-25
lines changed

9 files changed

+23
-25
lines changed

src/data/app.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
// Class of whole current application
16-
class App : Libraries {
16+
class App {
1717
private:
1818
// Flags of work
1919
static bool running;

src/data/libraries.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Libraries::Libraries() {
3333
if (!Mix_OpenAudio(audioDeviceID, NULL)) {
3434
throw LibararyLoadException("Couldn't initialase audio chanel: " + std::string(SDL_GetError()));
3535
}
36+
logAdditional("Libraries load correctly");
3637
#else
3738
SDL_Init(SDL_INIT_AUDIO | SDL_INIT_VIDEO);
3839
TTF_Init();

src/data/libraries.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* <nik.kazankov.05@mail.ru>
44
*/
55

6+
#pragma once
7+
68
#include <SDL3/SDL_audio.h>
79
#include "exceptions.hpp"
810

src/data/preloaded/loader/loader.cpp

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/define.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,16 @@
66
#pragma once
77

88
// System numbers
9-
#define WINDOW_NAME "Tic-tac-toe on SDL" // System game name
10-
#define CELL_SIDE 100 // Width and height of mine in pixels
11-
#define SEPARATOR 5 // Width of separator between cells in pixels
9+
#define WINDOW_NAME "Tic-tac-toe on SDL" // System game name
10+
#define CELL_SIDE 100 // Width and height of mine in pixels
11+
#define SEPARATOR 5 // Width of separator between cells in pixels
1212

1313
// Internet constants
1414
#define BASE_PORT 8000 // Base port to create/connect
1515
#define MAX_SEND_ID 128 // Maximal number of send message ID
1616
#define MESSAGE_GET_TIMEOUT 5000 // Time after which connection is considered lost
1717
#define MESSAGE_APPLY_TIMEOUT 2000 // Time to send apply message to keep connecion
1818
#define MESSAGE_RESEND_TIMEOUT 250 // Time after which need to resend message, as it was lost
19-
#define CONNECTION_LOST_PERCENT 0 // Option for better testing of connection stability
2019

2120
// Base file names
2221
#define SETTING_FILE "settings-tic-tac-toe.ini" // File with all starting data (width, height...)

src/game/gameField.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
float GameField::upperLineHeight;
1010
int GameField::offset;
11+
Field GameField::field{};
1112

1213
GameField::GameField(const Window& _window)
1314
: Template(_window) {}

src/main.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* <nik.kazankov.05@mail.ru>
44
*/
55

6-
#include "data/app.hpp"
6+
#include "data/libraries.hpp"
77
// Load needed loader, depend on teting
88
#if ARCHIEVE_LOADING
99
#include "data/preloaded/loader/archieveLoader.hpp"
@@ -16,12 +16,16 @@
1616
#include "cycles/selectCycle.hpp"
1717

1818

19+
// Selecting loader for data, depend on testing
20+
Libraries libraries;
21+
#if ARCHIEVE_LOADING
22+
const ArchieveLoader dataLoader{};
23+
#else
24+
const StraightLoader dataLoader{};
25+
#endif
1926
// Static game objects
2027
SoundsData sounds{};
2128
MusicData music{};
22-
Field GameField::field{};
23-
InitFile initFile{};
24-
2529

2630
// Main function
2731
int main(int argv, char **args) {

src/settingFile.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "cycles/clientLobby.hpp"
1414

1515

16+
InitFile initFile{};
17+
1618
// Data, load from setting file
1719
void InitFile::loadSettings() {
1820
// Reading file

src/testing.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77

88
// File for setting flags for all test for program
99
// Debuging modifiers
10-
#define DEBUG true
10+
#define DEBUG false
1111
#define CHECK_CORRECTION DEBUG
1212
#define CHECK_ALL DEBUG
13-
#define ARCHIEVE_LOADING DEBUG
13+
#define ARCHIEVE_LOADING !DEBUG
14+
15+
// Internet testing
16+
#define CONNECTION_LOST_PERCENT 0 // Testing connection stability

0 commit comments

Comments
 (0)