@@ -16,7 +16,7 @@ menu(_window) {
1616 connection.sendConfirmed (ConnectionCode::Init);
1717 field.restart ();
1818 // Sending first field
19- sendField ( );
19+ connection. sendConfirmed <Array< char >>(ConnectionCode::GameNew, field. getSave () );
2020 }
2121 logAdditional (" Start server game cycle" );
2222}
@@ -30,6 +30,7 @@ bool ServerGameCycle::inputMouseDown() {
3030 menu.addField (field.saveField ());
3131 // Showing message of sucsessful saving
3232 savedInfo.reset ();
33+ logAdditional (" Saving field" );
3334 }
3435 if (gameMenuButton.in (mouse)) {
3536 // Starting game menu
@@ -39,9 +40,12 @@ bool ServerGameCycle::inputMouseDown() {
3940 // Checking, if game start
4041 if (menu.isActive ()) {
4142 if (const Field* f = menu.click (mouse)) {
43+ // Setting new field localy
4244 field.setNewField (f, window);
43- sendField ();
45+ // Sending it
46+ connection.sendConfirmed <Array<char >>(ConnectionCode::GameNew, field.getSave ());
4447 menu.reset ();
48+ logAdditional (" Selecting new field" );
4549 }
4650 return true ;
4751 } else {
@@ -81,11 +85,11 @@ void ServerGameCycle::update() {
8185 if (connection.lastPacket ->isBytesAvaliable (3 )) {
8286 // Making turn
8387 field.clickMultiplayerOpponent (connection.lastPacket ->getData <Uint8>(2 ));
84- logAdditional (" Turn of opponent player to %u" , connection.lastPacket ->getData <Uint8>(2 ));
8588
8689 // Making sound
8790 sounds.play (Sounds::Turn);
8891 music.startFromCurrent (Music::MainCombat);
92+ logAdditional (" Turn of opponent player to %u" , connection.lastPacket ->getData <Uint8>(2 ));
8993 }
9094 return ;
9195
@@ -147,11 +151,3 @@ void ServerGameCycle::draw() const {
147151 // Bliting all to screen
148152 window.render ();
149153}
150-
151- void ServerGameCycle::sendField () {
152- // connection.sendConfirmed<Uint8, Uint8>(ConnectionCode::Init, field.getWidth(), field.getWinWidth());
153- // ! Need to write in correct way
154- field.saveField ();
155- const Array<char > s = field.getSave ();
156- connection.sendConfirmed <Array<char >>(ConnectionCode::GameNew, s);
157- }
0 commit comments