]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/minigames/minigame/ttt.qc
Tidy up classnames
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / minigames / minigame / ttt.qc
index c5a658054fe0d1e55192363b7e12cfd0abe9112b..bb642a282aa6c9acb9634d96b7f8d17422c3c74f 100644 (file)
@@ -1,5 +1,5 @@
 #include "ttt.qh"
-REGISTER_MINIGAME(ttt, "Tic Tac Toe");
+REGISTER_MINIGAME(ttt, _("Tic Tac Toe"));
 
 const int TTT_TURN_PLACE = 0x0100; // player has to place a piece on the board
 const int TTT_TURN_WIN   = 0x0200; // player has won
@@ -83,7 +83,7 @@ void ttt_move(entity minigame, entity player, string pos )
                if ( ttt_valid_tile(pos) )
                if ( !ttt_find_piece(minigame,pos) )
                {
-                       entity piece = msle_spawn(minigame,"minigame_board_piece");
+                       entity piece = msle_spawn(minigame,new(minigame_board_piece));
                        piece.team = player.team;
                        piece.netname = strzone(pos);
                        minigame_server_sendflags(piece,MINIG_SF_ALL);
@@ -147,7 +147,7 @@ int ttt_server_event(entity minigame, string event, ...)
                        while( (e = findentity(e, owner, minigame)) )
                        if(e.classname == "minigame_board_piece")
                        {
-                               if(e.netname) { strunzone(e.netname); }
+                               strfree(e.netname);
                                delete(e);
                        }
                        return false;
@@ -320,14 +320,16 @@ string ttt_turn_to_string(int turnflags)
 
        if ( turnflags & TTT_TURN_WIN )
        {
-               if ( (turnflags&TTT_TURN_TEAM) != minigame_self.team )
-                       return _("You lost the game!\nSelect \"^1Next Match^7\" on the menu for a rematch!");
-               return _("You win!\nSelect \"^1Next Match^7\" on the menu to start a new match!");
+               // translator-friendly messages composed of 2 existing messages
+               // TODO: proper "you win" banner instead of hijacking the help message
+               if ( (turnflags & TTT_TURN_TEAM) != minigame_self.team )
+                       return strcat(_("You lost the game!"), "\n", _("Select \"^1Next Match^7\" on the menu for a rematch!"));
+               return strcat(_("You win!"), "\n", _("Select \"^1Next Match^7\" on the menu to start a new match!"));
        }
 
        if ( turnflags & TTT_TURN_NEXT )
        {
-               if ( (turnflags&TTT_TURN_TEAM) != minigame_self.team )
+               if ( (turnflags & TTT_TURN_TEAM) != minigame_self.team )
                        return _("Select \"^1Next Match^7\" on the menu to start a new match!");
                return _("Wait for your opponent to confirm the rematch");
        }
@@ -520,7 +522,7 @@ void ttt_aimove(entity minigame)
                else
                        ttt_move(minigame,aiplayer,pos);
        }
-       minigame.message = ttt_turn_to_string(minigame.minigame_flags);
+       strcpy(minigame.message, ttt_turn_to_string(minigame.minigame_flags));
 }
 
 // Make the correct move
@@ -540,8 +542,7 @@ void ttt_make_move(entity minigame)
 
 void ttt_set_curr_pos(string s)
 {
-       if ( ttt_curr_pos )
-               strunzone(ttt_curr_pos);
+       strfree(ttt_curr_pos);
        if ( s )
                s = strzone(s);
        ttt_curr_pos = s;
@@ -555,7 +556,12 @@ int ttt_client_event(entity minigame, string event, ...)
                case "activate":
                {
                        ttt_set_curr_pos("");
-                       minigame.message = ttt_turn_to_string(minigame.minigame_flags);
+                       strcpy(minigame.message, ttt_turn_to_string(minigame.minigame_flags));
+                       return false;
+               }
+               case "deactivate":
+               {
+                       strfree(minigame.message);
                        return false;
                }
                case "key_pressed":
@@ -630,7 +636,7 @@ int ttt_client_event(entity minigame, string event, ...)
                        {
                                if ( sf & MINIG_SF_UPDATE )
                                {
-                                       sent.message = ttt_turn_to_string(sent.minigame_flags);
+                                       strcpy(sent.message, ttt_turn_to_string(sent.minigame_flags));
                                        if ( sent.minigame_flags & minigame_self.team )
                                                minigame_prompt();
                                }