]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/minigames/cl_minigames.qc
Replace print calls with logger calls
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / minigames / cl_minigames.qc
index f6af765b744b0f87eb2083f717d9b27e290aab86..3a1cc86744c16f9ea93f40c0a3ce22801cd874d6 100644 (file)
@@ -36,7 +36,7 @@ vector minigame_hud_normalize(vector v, vector pos, vector mySize)
 }
 
 // Check if the mouse is inside the given area
-float minigame_hud_mouse_in(vector pos, vector sz)
+bool minigame_hud_mouse_in(vector pos, vector sz)
 {
        return mousepos_x >= pos_x && mousepos_x < pos_x + sz_x &&
               mousepos_y >= pos_y && mousepos_y < pos_y + sz_y ;
@@ -51,9 +51,9 @@ void initialize_minigames()
                minig.classname = "minigame_descriptor"; \
                minig.netname = strzone(strtolower(#name)); \
                minig.message = nicename; \
-               minig.minigame_hud_board = minigame_hud_board_##name; \
-               minig.minigame_hud_status = minigame_hud_status_##name; \
-               minig.minigame_event = minigame_event_##name; \
+               minig.minigame_hud_board = name##_hud_board; \
+               minig.minigame_hud_status = name##_hud_status; \
+               minig.minigame_event = name##_client_event; \
                if ( !last_minig ) minigame_descriptors = minig; \
                else last_minig.list_next = minig; \
                last_minig = minig;
@@ -80,6 +80,7 @@ string minigame_texture(string name)
 #define MSLE_CLEAN_Byte(x)
 #define MSLE_CLEAN_Char(x)
 #define MSLE_CLEAN_Short(x)
+#define MSLE_CLEAN_Long(x)
 #define MSLE_CLEAN_Coord(x)
 #define MSLE_CLEAN_Angle(x)
 #define MSLE_CLEAN_Float(x)
@@ -94,20 +95,20 @@ MINIGAME_SIMPLELINKED_ENTITIES
 
 void minigame_autoclean_entity(entity e)
 {
-       dprint("CL Auto-cleaned: ",ftos(num_for_edict(e)), " (",e.classname,")\n");
+       LOG_TRACE("CL Auto-cleaned: ",ftos(num_for_edict(e)), " (",e.classname,")\n");
        remove(e);
 }
 
 void HUD_MinigameMenu_CurrentButton();
-float auto_close_minigamemenu;
+bool auto_close_minigamemenu;
 void deactivate_minigame()
 {
        if ( !active_minigame )
                return;
-       
+
        active_minigame.minigame_event(active_minigame,"deactivate");
        entity e = world;
-       while( (e = findentity(e, owner, self)) )
+       while( (e = findentity(e, owner, active_minigame)) )
                if ( e.minigame_autoclean )
                {
                        minigame_autoclean_entity(e);
@@ -115,7 +116,7 @@ void deactivate_minigame()
 
        minigame_self = world;
        active_minigame = world;
-       
+
        if ( auto_close_minigamemenu )
        {
                HUD_MinigameMenu_Close();
@@ -125,6 +126,12 @@ void deactivate_minigame()
                HUD_MinigameMenu_CurrentButton();
 }
 
+void minigame_entremove()
+{
+       if ( self == active_minigame )
+               deactivate_minigame();
+}
+
 void activate_minigame(entity minigame)
 {
        if ( !minigame )
@@ -135,7 +142,7 @@ void activate_minigame(entity minigame)
        
        if ( !minigame.descriptor || minigame.classname != "minigame" )
        {
-               dprint("Trying to activate unregistered minigame ",minigame.netname," in client\n");
+               LOG_TRACE("Trying to activate unregistered minigame ",minigame.netname," in client\n");
                return;
        }
        
@@ -144,9 +151,7 @@ void activate_minigame(entity minigame)
        
        if ( active_minigame )
        {
-               entity olds = minigame_self;
                deactivate_minigame();
-               minigame_self = olds;
        }
        
        if ( minigame_self.owner != minigame )
@@ -173,7 +178,6 @@ vector ReadVector2D() { vector v; v_x = ReadCoord(); v_y = ReadCoord(); v_z = 0;
 vector ReadVector() { vector v; v_x = ReadCoord(); v_y = ReadCoord(); v_z = ReadCoord(); return v; }
 string() ReadString_Raw = #366;
 string ReadString_Zoned() { return strzone(ReadString_Raw()); }
-#define ReadFloat ReadCoord
 #define ReadString ReadString_Zoned
 #define FIELD(Flags, Type,Name) if ( sf & (Flags) ) self.Name = Read##Type();
 #define MSLE(Name,Fields) \
@@ -193,7 +197,7 @@ void minigame_read_owner()
                self.owner = find(self.owner,netname,owner_name);
        while ( self.owner && self.owner.classname != "minigame" );
        if ( !self.owner )
-               dprint("Got a minigame entity without a minigame!\n");
+               LOG_TRACE("Got a minigame entity without a minigame!\n");
 }
 void ent_read_minigame()
 {
@@ -212,10 +216,10 @@ void ent_read_minigame()
                
                if ( sf & MINIG_SF_CREATE )
                {
-                       self.entremove = deactivate_minigame;
+                       self.entremove = minigame_entremove;
                        self.descriptor = minigame_get_descriptor(ReadString_Raw());
                        if ( !self.descriptor )
-                               dprint("Got a minigame without a client-side descriptor!\n");
+                               LOG_TRACE("Got a minigame without a client-side descriptor!\n");
                        else
                                self.minigame_event = self.descriptor.minigame_event;
                }
@@ -231,7 +235,7 @@ void ent_read_minigame()
                        minigame_read_owner();
                        float ent = ReadLong();
                        self.minigame_playerslot = ent;
-                       dprint("Player: ",GetPlayerName(ent-1),"\n");
+                       LOG_TRACE("Player: ",GetPlayerName(ent-1),"\n");
                        
                        activate = (ent == player_localnum+1 && self.owner && self.owner != active_minigame);
                        
@@ -251,22 +255,24 @@ void ent_read_minigame()
        
        if ( minigame_ent )
                minigame_ent.minigame_event(minigame_ent,"network_receive",self,sf);
-       
-       dprint("CL Reading entity: ",ftos(num_for_edict(self)),
-               " classname:",self.classname," enttype:",ftos(self.enttype) );
-       dprint(" sf:",ftos(sf)," netname:",self.netname,"\n\n");
+
+       if ( sf & MINIG_SF_CREATE )
+       {
+               LOG_TRACE("CL Reading entity: ",ftos(num_for_edict(self)),
+                       " classname:",self.classname," enttype:",ftos(self.enttype) );
+               LOG_TRACE(" sf:",ftos(sf)," netname:",self.netname,"\n\n");
+       }
 }
-#undef ReadFloat
 #undef ReadString
 #undef FIELD
 #undef MSLE
 
 string minigame_getWrappedLine(float w, vector theFontSize, textLengthUpToWidth_widthFunction_t tw)
 {
-       float last_word;
+       int last_word;
        string s;
-       float take_until;
-       float skip = 0;
+       int take_until;
+       int skip = 0;
 
        s = getWrappedLine_remaining;
 
@@ -280,9 +286,8 @@ string minigame_getWrappedLine(float w, vector theFontSize, textLengthUpToWidth_
        
        if ( take_until > strlen(s) )
                take_until = strlen(s);
-       
-       float i;
-       for ( i = 0; i < take_until; i++ )
+
+       for ( int i = 0; i < take_until; i++ )
                if ( substring(s,i,1) == "\n" )
                {
                        take_until = i;
@@ -320,7 +325,7 @@ string minigame_getWrappedLine(float w, vector theFontSize, textLengthUpToWidth_
 }
 
 vector minigame_drawstring_wrapped( float maxwidth, vector pos, string text, 
-       vector fontsize, vector color, float theAlpha, float drawflags, float align )
+       vector fontsize, vector color, float theAlpha, int drawflags, float align )
 {      
        getWrappedLine_remaining = text;
        vector mypos = pos;
@@ -339,7 +344,7 @@ vector minigame_drawstring_wrapped( float maxwidth, vector pos, string text,
 }
 
 vector minigame_drawcolorcodedstring_wrapped( float maxwidth, vector pos, 
-       string text, vector fontsize, float theAlpha, float drawflags, float align )
+       string text, vector fontsize, float theAlpha, int drawflags, float align )
 {
        getWrappedLine_remaining = text;
        vector mypos = pos;
@@ -358,21 +363,21 @@ vector minigame_drawcolorcodedstring_wrapped( float maxwidth, vector pos,
 }
 
 void minigame_drawstring_trunc(float maxwidth, vector pos, string text, 
-       vector fontsize, vector color, float theAlpha, float drawflags )
+       vector fontsize, vector color, float theAlpha, int drawflags )
 {
        string line = textShortenToWidth(text,maxwidth,fontsize,stringwidth_nocolors);
        drawstring(pos, line, fontsize, color, theAlpha, drawflags);
 }
 
 void minigame_drawcolorcodedstring_trunc(float maxwidth, vector pos, string text, 
-       vector fontsize, float theAlpha, float drawflags )
+       vector fontsize, float theAlpha, int drawflags )
 {
        string line = textShortenToWidth(text,maxwidth,fontsize,stringwidth_colors);
        drawcolorcodedstring(pos, line, fontsize, theAlpha, drawflags);
 }
 
 void minigame_drawpic_centered( vector pos, string texture, vector sz, 
-       vector color, float thealpha, float drawflags )
+       vector color, float thealpha, int drawflags )
 {
        drawpic( pos-sz/2, texture, sz, color, thealpha, drawflags );
 }
@@ -398,4 +403,4 @@ void minigame_prompt()
                HUD_Notify_Push(sprintf("minigames/%s/icon_notif",active_minigame.descriptor.netname),
                        _("It's your turn"), "");
        }
-}
\ No newline at end of file
+}