]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Put some more work into the config system
authorSamual Lenks <samual@xonotic.org>
Sat, 29 Jun 2013 23:59:27 +0000 (19:59 -0400)
committerSamual Lenks <samual@xonotic.org>
Sat, 29 Jun 2013 23:59:27 +0000 (19:59 -0400)
qcsrc/common/constants.qh
qcsrc/common/weapons/config.qc
qcsrc/common/weapons/config.qh
qcsrc/common/weapons/w_devastator.qc
qcsrc/common/weapons/weapons.qh
qcsrc/server/progs.src

index 0fc1a98be86efe50746e732ab4ba17741945dae4..3b5073e875f78a351f6dc0ec9032cacb639dc976 100644 (file)
@@ -376,24 +376,6 @@ float WATERLEVEL_WETFEET = 1;
 float WATERLEVEL_SWIMMING = 2;
 float WATERLEVEL_SUBMERGED = 3;
 
-float MAX_SHOT_DISTANCE = 32768;
-
-// weapon requests
-float WR_SETUP         = 1; // (SVQC) setup weapon data
-float WR_THINK         = 2; // (SVQC) logic to run every frame
-float WR_CHECKAMMO1    = 3; // (SVQC) checks ammo for weapon
-float WR_CHECKAMMO2    = 4; // (SVQC) checks ammo for weapon
-float WR_AIM           = 5; // (SVQC) runs bot aiming code for this weapon
-float WR_PRECACHE      = 6; // (CSQC and SVQC) precaches models/sounds used by this weapon
-float WR_SUICIDEMESSAGE = 7; // (SVQC) notification number for suicide message (may inspect w_deathtype for details)
-float WR_KILLMESSAGE    = 8; // (SVQC) notification number for kill message (may inspect w_deathtype for details)
-float WR_RELOAD         = 9; // (SVQC) does not need to do anything
-float WR_RESETPLAYER    = 10; // (SVQC) does not need to do anything
-float WR_IMPACTEFFECT  = 11; // (CSQC) impact effect
-float WR_SWITCHABLE    = 12; // (CSQC) impact effect
-float WR_PLAYERDEATH    = 13; // (SVQC) does not need to do anything
-float WR_GONETHINK     = 14; // (SVQC) logic to run every frame, also if no longer having the weapon as long as the switch away has not been performed
-
 #define SERVERFLAG_ALLOW_FULLBRIGHT 1
 #define SERVERFLAG_TEAMPLAY 2
 #define SERVERFLAG_PLAYERSTATS 4
index 454ee22a2396b93458a4461c72d6561dd9d1c711..9e05602f880d5fb63f094c22b5a22780061a1387 100644 (file)
@@ -10,7 +10,7 @@ void Dump_Weapon_Settings(float fh, float alsoprint)
                WEP_ACTION(i, WR_CONFIG)
        }
 
-                       
+       /*
        #define WEP_BAL_WRITE(a) { \
                fputs(fh, a); \
                if(alsoprint) { print(a); } }
@@ -107,5 +107,5 @@ void Dump_Weapon_Settings(float fh, float alsoprint)
        return;
        #undef NOTIF_WRITE_HARDCODED
        #undef NOTIF_WRITE_ENTITY
-       #undef NOTIF_WRITE
+       #undef NOTIF_WRITE*/
 }
index 454ee22a2396b93458a4461c72d6561dd9d1c711..462c988d77b3ab0ee95e4bc39cf9785a3e12ce92 100644 (file)
 //  Balance Config Generator
 // ==========================
 
-void Dump_Weapon_Settings(float fh, float alsoprint)
-{
-       float i;
-       for(i = WEP_FIRST; i <= WEP_LAST; ++i)
-       {
-               WEP_ACTION(i, WR_CONFIG)
-       }
-
-                       
-       #define WEP_BAL_WRITE(a) { \
-               fputs(fh, a); \
-               if(alsoprint) { print(a); } }
-       #define WEP_BAL_WRITE_ENTITY(description) { \
-               notif_msg = \
-                       sprintf( \
-                               "seta notification_%s \"%d\" \"%s\"\n", \
-                               e.nent_name, e.nent_default, description \
-                       ); \
-               WEP_BAL_WRITE(notif_msg) }
-       #define WEP_BAL_WRITE_HARDCODED(cvar,default,description) { \
-               notif_msg = \
-                       sprintf( \
-                               "seta notification_%s \"%s\" \"%s\"\n", \
-                               cvar, default, description \
-                       ); \
-               WEP_BAL_WRITE(notif_msg) }
-
-       string notif_msg;
-       float i;
-       entity e;
-
-       NOTIF_WRITE(sprintf("\n// MSG_ANNCE notifications (count = %d):\n", NOTIF_ANNCE_COUNT));
-       for(i = 1; i <= NOTIF_ANNCE_COUNT; ++i)
-       {
-               e = Get_Notif_Ent(MSG_ANNCE, i);
-               if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
-               
-               NOTIF_WRITE_ENTITY(
-                       "Notification control cvar: 0 = disabled, 1 = enabled if gentle mode is off, 2 = always enabled)"
-               );
-       }
-
-       NOTIF_WRITE(sprintf("\n// MSG_INFO notifications (count = %d):\n", NOTIF_INFO_COUNT));
-       for(i = 1; i <= NOTIF_INFO_COUNT; ++i)
-       {
-               e = Get_Notif_Ent(MSG_INFO, i);
-               if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
-               
-               NOTIF_WRITE_ENTITY(
-                       "Notification control cvar: 0 = off, 1 = print to console, "
-                       "2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)"
-               );
-       }
-
-       NOTIF_WRITE(sprintf("\n// MSG_CENTER notifications (count = %d):\n", NOTIF_CENTER_COUNT));
-       for(i = 1; i <= NOTIF_CENTER_COUNT; ++i)
-       {
-               e = Get_Notif_Ent(MSG_CENTER, i);
-               if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
-               
-               NOTIF_WRITE_ENTITY(
-                       "Notification control cvar: 0 = off, 1 = centerprint"
-               );
-       }
-
-       NOTIF_WRITE(sprintf("\n// MSG_MULTI notifications (count = %d):\n", NOTIF_MULTI_COUNT));
-       for(i = 1; i <= NOTIF_MULTI_COUNT; ++i)
-       {
-               e = Get_Notif_Ent(MSG_MULTI, i);
-               if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; }
-               
-               NOTIF_WRITE_ENTITY(
-                       "Notification control cvar: 0 = off, 1 = trigger subcalls"
-               );
-       }
-
-       // edit these to match whichever cvars are used for specific notification options
-       NOTIF_WRITE("\n// HARD CODED notification variables:\n");
-       
-       NOTIF_WRITE_HARDCODED(
-               "allow_chatboxprint", "1",
-               "Allow notifications to be printed to chat box by setting notification cvar to 2 "
-               "(You can also set this cvar to 2 to force ALL notifications to be printed to the chatbox)"
-       );
-
-       NOTIF_WRITE(sprintf(
-               strcat(
-                       "\n// Notification counts (total = %d): ",
-                       "MSG_ANNCE = %d, MSG_INFO = %d, MSG_CENTER = %d, MSG_MULTI = %d\n"
-               ),
-               (
-                       NOTIF_ANNCE_COUNT +
-                       NOTIF_INFO_COUNT +
-                       NOTIF_CENTER_COUNT +
-                       NOTIF_MULTI_COUNT
-               ),
-               NOTIF_ANNCE_COUNT,
-               NOTIF_INFO_COUNT,
-               NOTIF_CENTER_COUNT,
-               NOTIF_MULTI_COUNT
-       ));
+void Dump_Weapon_Settings(float fh, float alsoprint);
+float wep_config_file;
+float wep_config_alsoprint;
+
+#define WEP_CONFIG_WRITE(a) { \
+       fputs(wep_config_file, a); \
+       if(wep_config_alsoprint) { print(a); } }
+
+#define WEP_CONFIG_WRITE_CVARS(weapon,mode,name) \
+       #if mode == MO_PRI \
+               WEP_CONFIG_WRITE(sprintf("set g_balance_%s_primary_%s", #weapon, #name)) \
+       #endif \
+       #if mode == MO_SEC \
+               WEP_CONFIG_WRITE(sprintf("set g_balance_%s_secondary_%s", #weapon, #name)) \
+       #endif \
+       #if mode == MO_BOTH \
+               WEP_CONFIG_WRITE(sprintf("set g_balance_%s_primary_%s", #weapon, #name)) \
+               WEP_CONFIG_WRITE(sprintf("set g_balance_%s_secondary_%s", #weapon, #name)) \
+       #endif \
+       #if mode == MO_NONE \
+               WEP_CONFIG_WRITE(sprintf("set g_balance_%s_%s", #weapon, #name)) \
+       #endif
        
-       return;
-       #undef NOTIF_WRITE_HARDCODED
-       #undef NOTIF_WRITE_ENTITY
-       #undef NOTIF_WRITE
-}
+#define WEP_CONFIG_WRITE_PROPS(weapon,prop,name) \
+       { WEP_CONFIG_WRITE(sprintf("set g_balance_%s_%s", #weapon, #name)) }
index c239d70ff1099cb3ffe979a873e28a4f8e311797..e30c8746e30edb2f2c2c6c57040b089e97083e62 100644 (file)
@@ -455,13 +455,13 @@ float W_Devastator(float req)
                {
                        if(autocvar_sv_precacheweapons)
                        {
-                               precache_model ("models/flash.md3");
-                               precache_model ("models/weapons/g_rl.md3");
-                               precache_model ("models/weapons/v_rl.md3");
-                               precache_model ("models/weapons/h_rl.iqm");
-                               precache_sound ("weapons/rocket_det.wav");
-                               precache_sound ("weapons/rocket_fire.wav");
-                               precache_sound ("weapons/rocket_mode.wav");
+                               precache_model("models/flash.md3");
+                               precache_model("models/weapons/g_rl.md3");
+                               precache_model("models/weapons/v_rl.md3");
+                               precache_model("models/weapons/h_rl.iqm");
+                               precache_sound("weapons/rocket_det.wav");
+                               precache_sound("weapons/rocket_fire.wav");
+                               precache_sound("weapons/rocket_mode.wav");
                        }
 
                        #define WEP_ADD_CVAR(weapon,mode,name) /*nothing*/
@@ -471,38 +471,16 @@ float W_Devastator(float req)
                        #undef WEP_ADD_PROP
                        
                        return TRUE;
-               }/*
+               }
                case WR_CONFIG:
                {
-                       
-                       #define WEP_CONFIG_WRITE(a) { \
-                               fputs(wep_config_file, a); \
-                               if(wep_config_alsoprint) { print(a); } }
-
-                       #define WEP_CONFIG_WRITE_CVAR(cvarstring) \
-                               { WEP_CONFIG_WRITE(sprintf(cvarstring, weapon, #name)); }
-                               
-                       #define WEP_ADD_CVAR(weapon,mode,name) \
-                               #if mode == MO_PRI \
-                                       WEP_CONFIG_WRITE_CVAR("set g_balance_%s_primary_%s") \
-                               #endif \
-                               #if mode == MO_SEC \
-                                       WEP_CONFIG_WRITE_CVAR("set g_balance_%s_secondary_%s") \
-                               #endif \
-                               #if mode == MO_BOTH \
-                                       WEP_CONFIG_WRITE_CVAR("set g_balance_%s_primary_%s") \
-                                       WEP_CONFIG_WRITE_CVAR("set g_balance_%s_secondary_%s") \
-                               #endif \
-                               #if mode == MO_NONE \
-                                       WEP_CONFIG_WRITE_CVAR("set g_balance_%s_%s") \
-                               #endif
-                               
-                       #define WEP_ADD_PROP(weapon,prop,name) WEP_CONFIG_WRITE_CVAR("set g_balance_%s_%s")
+                       #define WEP_ADD_CVAR(weapon,mode,name) WEP_CONFIG_WRITE_CVARS(weapon,mode,name)
+                       #define WEP_ADD_PROP(weapon,prop,name) WEP_CONFIG_WRITE_PROPS(weapon,mode,name)
                        ARC_SETTINGS(devastator)
                        #undef WEP_ADD_CVAR
                        #undef WEP_ADD_PROP
                        return TRUE;
-               }*/
+               }
                case WR_SETUP:
                {
                        weapon_setup(WEP_DEVASTATOR);
index 2ce6fa5d8c80defbd18302e6b42096a7f00094a3..4bf4a694b449bb9341e6f5de4201556e9c2accea 100644 (file)
@@ -17,6 +17,26 @@ float WEP_FLAG_RELOADABLE     =  0x80; // can has reload
 float WEP_FLAG_SUPERWEAPON    = 0x100; // powerup timer
 float WEP_FLAG_MUTATORBLOCKED = 0x200; // hides from impulse 99 etc. (mutators are allowed to clear this flag)
 
+float MAX_SHOT_DISTANCE = 32768;
+
+// weapon requests // WEAPONTODO
+float WR_SETUP         = 1; // (SVQC) setup weapon data
+float WR_THINK         = 2; // (SVQC) logic to run every frame
+float WR_CHECKAMMO1    = 3; // (SVQC) checks ammo for weapon
+float WR_CHECKAMMO2    = 4; // (SVQC) checks ammo for weapon
+float WR_AIM           = 5; // (SVQC) runs bot aiming code for this weapon
+float WR_PRECACHE      = 6; // (CSQC and SVQC) precaches models/sounds used by this weapon
+float WR_SUICIDEMESSAGE = 7; // (SVQC) notification number for suicide message (may inspect w_deathtype for details)
+float WR_KILLMESSAGE    = 8; // (SVQC) notification number for kill message (may inspect w_deathtype for details)
+float WR_RELOAD         = 9; // (SVQC) does not need to do anything
+float WR_RESETPLAYER    = 10; // (SVQC) does not need to do anything
+float WR_IMPACTEFFECT  = 11; // (CSQC) impact effect
+float WR_SWITCHABLE    = 12; // (CSQC) impact effect
+float WR_PLAYERDEATH    = 13; // (SVQC) does not need to do anything
+float WR_GONETHINK     = 14; // (SVQC) logic to run every frame, also if no longer having the weapon as long as the switch away has not been performed
+float WR_CONFIG = 15;
+
+// WEAPONTODO
 float  IT_UNLIMITED_WEAPON_AMMO     = 1;
 // when this bit is set, using a weapon does not reduce ammo. Checkpoints can give this powerup.
 float  IT_UNLIMITED_SUPERWEAPONS    = 2;
index 0014d32ffd26cb55ae8b6fc765697760ed4386c7..b7e822d1a1b183bd7be100b26f12286cff61b177 100644 (file)
@@ -18,6 +18,7 @@ sys-post.qh
 ../common/test.qh
 ../common/counting.qh
 weapons/cl_weapons.qh
+../common/weapons/config.qh
 ../common/weapons/weapons.qh // WEAPONTODO
 ../common/urllib.qh
 ../common/command/markup.qh