r3137 - in trunk/data: . qcsrc/common qcsrc/server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Sun Jan 13 09:55:54 EST 2008
Author: div0
Date: 2008-01-13 09:55:54 -0500 (Sun, 13 Jan 2008)
New Revision: 3137
Modified:
trunk/data/default.cfg
trunk/data/qcsrc/common/mapinfo.qc
trunk/data/qcsrc/common/mapinfo.qh
trunk/data/qcsrc/server/defs.qh
trunk/data/qcsrc/server/g_world.qc
trunk/data/qcsrc/server/t_items.qc
trunk/data/qcsrc/server/t_quake3.qc
Log:
next improvement to mapinfo: Q3A SG/MG swap, mapinfo now applies map-specific settings at the RIGHT time
Modified: trunk/data/default.cfg
===================================================================
--- trunk/data/default.cfg 2008-01-13 11:18:11 UTC (rev 3136)
+++ trunk/data/default.cfg 2008-01-13 14:55:54 UTC (rev 3137)
@@ -842,3 +842,6 @@
// for menu server list (eventually make them have engine support?)
seta menu_slist_showfull 1
seta menu_slist_showempty 1
+
+// Q3A
+set sv_q3acompat_machineshotgunswap 0 // settemp this in mapinfo for instant Q3A map conversion
Modified: trunk/data/qcsrc/common/mapinfo.qc
===================================================================
--- trunk/data/qcsrc/common/mapinfo.qc 2008-01-13 11:18:11 UTC (rev 3136)
+++ trunk/data/qcsrc/common/mapinfo.qc 2008-01-13 14:55:54 UTC (rev 3137)
@@ -1,3 +1,28 @@
+// internal toy
+void cvar_settemp(string key, string value)
+{
+ //localcmd(strcat("\nsettemp ", t, " \"", s, "\"\n"));
+
+ // duplicate what this alias does:
+ // alias settemp "settemp_list \"1 $1 $settemp_var $settemp_list\"; set $settemp_var \"${$1}\"; settemp_var ${settemp_var}x; $1 \"$2\""
+
+ cvar_set("settemp_list", strcat("1 ", key, " ", cvar_string("settemp_var"), " ", cvar_string("settemp_list")));
+ registercvar(cvar_string("settemp_var"), "");
+ cvar_set(cvar_string("settemp_var"), cvar_string(key));
+ cvar_set("settemp_var", strcat(cvar_string("settemp_var"), "x"));
+ cvar_set(key, value);
+}
+
+void cvar_settemp_restore()
+{
+ // undo what cvar_settemp did
+ float n, i;
+ n = tokenize(cvar_string("settemp_list"));
+ for(i = 0; i < n - 3; i += 3)
+ cvar_set(argv(i + 1), cvar_string(argv(i + 2)));
+ cvar_set("settemp_list", "0");
+}
+
// HUGE SET - stored in a string
string HugeSetOfIntegers_empty()
{
@@ -282,6 +307,7 @@
}
fclose(fh);
+
return r;
}
@@ -342,7 +368,7 @@
{
string fn;
string s, t;
- float fh;
+ float fh, fh2;
float r, f;
r = 1;
@@ -377,6 +403,14 @@
if(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_KEYHUNT) fputs(fh, "type kh 1000 20 3\n");
if(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_ASSAULT) fputs(fh, "type as 20\n");
if(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_ONSLAUGHT) fputs(fh, "type ons 20\n");
+
+ fh2 = fopen(strcat("scripts/", pFilename, ".arena"), FILE_READ);
+ if(fh2 >= 0)
+ {
+ fclose(fh2);
+ fputs(fh, "settemp_for_type all sv_q3acompat_machineshotgunswap 1\n");
+ }
+
fclose(fh);
r = 2;
// return r;
@@ -440,7 +474,7 @@
else
{
dprint("Applying temporary setting ", t, " := ", s, "\n");
- localcmd(strcat("\nsettemp ", t, " \"", s, "\"\n"));
+ cvar_settemp(t, s);
}
}
}
@@ -561,28 +595,27 @@
void MapInfo_SwitchGameType(float t)
{
cvar_set("gamecfg", "0");
- cvar_set("g_dm", (t == MAPINFO_TYPE_DEATHMATCH) ? "0" : "1");
- cvar_set("g_tdm", (t == MAPINFO_TYPE_TEAM_DEATHMATCH) ? "0" : "1");
- cvar_set("g_domination", (t == MAPINFO_TYPE_DOMINATION) ? "0" : "1");
- cvar_set("g_ctf", (t == MAPINFO_TYPE_CTF) ? "0" : "1");
- cvar_set("g_runematch", (t == MAPINFO_TYPE_RUNEMATCH) ? "0" : "1");
- cvar_set("g_lms", (t == MAPINFO_TYPE_LMS) ? "0" : "1");
- cvar_set("g_arena", (t == MAPINFO_TYPE_ARENA) ? "0" : "1");
- cvar_set("g_keyhunt", (t == MAPINFO_TYPE_KEYHUNT) ? "0" : "1");
- cvar_set("g_assault", (t == MAPINFO_TYPE_ASSAULT) ? "0" : "1");
- cvar_set("g_onslaught", (t == MAPINFO_TYPE_ONSLAUGHT) ? "0" : "1");
+ cvar_set("g_dm", (t == MAPINFO_TYPE_DEATHMATCH) ? "1" : "0");
+ cvar_set("g_tdm", (t == MAPINFO_TYPE_TEAM_DEATHMATCH) ? "1" : "0");
+ cvar_set("g_domination", (t == MAPINFO_TYPE_DOMINATION) ? "1" : "0");
+ cvar_set("g_ctf", (t == MAPINFO_TYPE_CTF) ? "1" : "0");
+ cvar_set("g_runematch", (t == MAPINFO_TYPE_RUNEMATCH) ? "1" : "0");
+ cvar_set("g_lms", (t == MAPINFO_TYPE_LMS) ? "1" : "0");
+ cvar_set("g_arena", (t == MAPINFO_TYPE_ARENA) ? "1" : "0");
+ cvar_set("g_keyhunt", (t == MAPINFO_TYPE_KEYHUNT) ? "1" : "0");
+ cvar_set("g_assault", (t == MAPINFO_TYPE_ASSAULT) ? "1" : "0");
+ cvar_set("g_onslaught", (t == MAPINFO_TYPE_ONSLAUGHT) ? "1" : "0");
}
void MapInfo_LoadMap(string s)
{
+ MapInfo_Map_supportedGametypes = 0;
if(!MapInfo_CheckMap(s))
{
- print("EMERGENCY: can't play the selected map in the given game mode. Falling back to deathmatch.\n");
+ print("EMERGENCY: can't play the selected map in the given game mode. Falling back to DM.\n");
MapInfo_SwitchGameType(MAPINFO_TYPE_DEATHMATCH);
}
- localcmd("\nsettemp_restore\n");
- MapInfo_Get_ByName(s, 1, MapInfo_CurrentGametype());
- localcmd(strcat("\nchangelevel ", s, "\n"));
+ localcmd(strcat("\nsettemp_restore\nchangelevel ", s, "\n"));
}
string MapInfo_ListAllowedMaps()
@@ -599,3 +632,28 @@
out = strcat(out, " ", _MapInfo_GlobItem(HugeSetOfIntegers_get(_MapInfo_filtered, i)));
return substring(out, 1, strlen(out) - 1);
}
+
+void MapInfo_LoadMapSettings(string s) // to be called from worldspawn
+{
+ float t;
+ if(!MapInfo_CheckMap(s))
+ {
+ if(MapInfo_Map_supportedGametypes <= 0)
+ error("Mapinfo system is not functional at all. BAILED OUT.\n");
+
+ t = 1;
+ while(!(MapInfo_Map_supportedGametypes & 1))
+ {
+ t *= 2;
+ MapInfo_Map_supportedGametypes = floor(MapInfo_Map_supportedGametypes / 2);
+ }
+ // t is now a supported mode!
+ print("EMERGENCY: can't play the selected map in the given game mode. Falling back to a supported mode.\n");
+ print(ftos(t), "\n");
+ MapInfo_SwitchGameType(t);
+ print(ftos(MapInfo_CurrentGametype()), "\n");
+ }
+ print(ftos(MapInfo_CurrentGametype()), "\n");
+ cvar_settemp_restore();
+ MapInfo_Get_ByName(s, 1, MapInfo_CurrentGametype());
+}
Modified: trunk/data/qcsrc/common/mapinfo.qh
===================================================================
--- trunk/data/qcsrc/common/mapinfo.qh 2008-01-13 11:18:11 UTC (rev 3136)
+++ trunk/data/qcsrc/common/mapinfo.qh 2008-01-13 14:55:54 UTC (rev 3137)
@@ -54,3 +54,6 @@
// gets a gametype from a string
float MapInfo_Type_FromString(string t);
void MapInfo_SwitchGameType(float t);
+
+// to be called from worldspawn to set up cvars
+void MapInfo_LoadMapSettings(string s);
Modified: trunk/data/qcsrc/server/defs.qh
===================================================================
--- trunk/data/qcsrc/server/defs.qh 2008-01-13 11:18:11 UTC (rev 3136)
+++ trunk/data/qcsrc/server/defs.qh 2008-01-13 14:55:54 UTC (rev 3137)
@@ -380,3 +380,4 @@
.float notsingle;
.float notfree;
.float notq3a;
+float q3acompat_machineshotgunswap;
Modified: trunk/data/qcsrc/server/g_world.qc
===================================================================
--- trunk/data/qcsrc/server/g_world.qc 2008-01-13 11:18:11 UTC (rev 3136)
+++ trunk/data/qcsrc/server/g_world.qc 2008-01-13 14:55:54 UTC (rev 3137)
@@ -90,6 +90,10 @@
error("world already spawned - you may have EXACTLY ONE worldspawn!");
world_already_spawned = TRUE;
+#ifdef MAPINFO
+ MapInfo_LoadMapSettings(mapname);
+#endif
+
/*
TODO sound pack system
// initialize sound pack system
@@ -140,6 +144,10 @@
// 63 testing
lightstyle(63, "a");
+ // for setting by mapinfo
+ q3acompat_machineshotgunswap = cvar("sv_q3acompat_machineshotgunswap");
+ cvar_set("sv_q3acompat_machineshotgunswap", "0");
+
player_count = 0;
lms_lowest_lives = 0;
lms_next_place = 0;
Modified: trunk/data/qcsrc/server/t_items.qc
===================================================================
--- trunk/data/qcsrc/server/t_items.qc 2008-01-13 11:18:11 UTC (rev 3136)
+++ trunk/data/qcsrc/server/t_items.qc 2008-01-13 14:55:54 UTC (rev 3137)
@@ -527,7 +527,20 @@
remove(self);
}
+float weaponswapping;
+
+void weapon_shotgun (void);
void weapon_uzi (void) {
+ if(!weaponswapping)
+ if(q3acompat_machineshotgunswap)
+ if(self.classname != "droppedweapon")
+ {
+ weaponswapping = TRUE;
+ weapon_shotgun();
+ weaponswapping = FALSE;
+ return;
+ }
+
if(!self.ammo_nails)
self.ammo_nails = cvar("g_pickup_nails");
StartItem ("models/weapons/g_uzi.md3", "weapons/weaponpickup.wav", 15, W_Name(WEP_UZI), IT_UZI, FL_WEAPON, weapon_pickupevalfunc, 1000);
@@ -536,6 +549,16 @@
}
void weapon_shotgun (void) {
+ if(!weaponswapping)
+ if(q3acompat_machineshotgunswap)
+ if(self.classname != "droppedweapon")
+ {
+ weaponswapping = TRUE;
+ weapon_uzi();
+ weaponswapping = FALSE;
+ return;
+ }
+
if(!self.ammo_shells)
self.ammo_shells = cvar("g_pickup_shells");
StartItem ("models/weapons/g_shotgun.md3", "weapons/weaponpickup.wav", 15, W_Name(WEP_SHOTGUN), IT_SHOTGUN, FL_WEAPON, weapon_pickupevalfunc, 1000);
@@ -623,7 +646,18 @@
StartItem ("models/items/a_rockets.md3", "misc/itempickup.wav", 15, "rockets", IT_ROCKETS, 0, commodity_pickupevalfunc, 100);
}
+void item_shells (void);
void item_bullets (void) {
+ if(!weaponswapping)
+ if(q3acompat_machineshotgunswap)
+ if(self.classname != "droppedweapon")
+ {
+ weaponswapping = TRUE;
+ item_shells();
+ weaponswapping = FALSE;
+ return;
+ }
+
if(!self.ammo_nails)
self.ammo_nails = g_pickup_nails;
StartItem ("models/items/a_bullets.mdl", "misc/itempickup.wav", 15, "bullets", IT_NAILS, 0, commodity_pickupevalfunc, 100);
@@ -636,6 +670,16 @@
}
void item_shells (void) {
+ if(!weaponswapping)
+ if(q3acompat_machineshotgunswap)
+ if(self.classname != "droppedweapon")
+ {
+ weaponswapping = TRUE;
+ item_bullets();
+ weaponswapping = FALSE;
+ return;
+ }
+
if(!self.ammo_shells)
self.ammo_shells = g_pickup_shells;
StartItem ("models/items/a_shells.md3", "misc/itempickup.wav", 15, "shells", IT_SHELLS, 0, commodity_pickupevalfunc, 100);
Modified: trunk/data/qcsrc/server/t_quake3.qc
===================================================================
--- trunk/data/qcsrc/server/t_quake3.qc 2008-01-13 11:18:11 UTC (rev 3136)
+++ trunk/data/qcsrc/server/t_quake3.qc 2008-01-13 14:55:54 UTC (rev 3137)
@@ -50,3 +50,5 @@
void spawnfunc_team_CTF_blueflag() { item_flag_team2(); }
void spawnfunc_team_CTF_redplayer() { info_player_team1(); }
void spawnfunc_team_CTF_blueplayer() { info_player_team2(); }
+void spawnfunc_team_CTF_redspawn() { info_player_team1(); }
+void spawnfunc_team_CTF_bluespawn() { info_player_team2(); }
More information about the nexuiz-commits
mailing list