r5022 - in trunk/data/qcsrc: client common menu menu/nexuiz server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Nov 9 05:11:57 EST 2008


Author: div0
Date: 2008-11-09 05:11:56 -0500 (Sun, 09 Nov 2008)
New Revision: 5022

Added:
   trunk/data/qcsrc/common/items.qc
   trunk/data/qcsrc/common/items.qh
Modified:
   trunk/data/qcsrc/client/progs.src
   trunk/data/qcsrc/common/constants.qh
   trunk/data/qcsrc/common/util.qc
   trunk/data/qcsrc/common/util.qh
   trunk/data/qcsrc/menu/menu.qc
   trunk/data/qcsrc/menu/nexuiz/dialog_multiplayer_create_mutators.c
   trunk/data/qcsrc/menu/nexuiz/weaponslist.c
   trunk/data/qcsrc/menu/progs.src
   trunk/data/qcsrc/server/cl_weapons.qc
   trunk/data/qcsrc/server/cl_weaponsystem.qc
   trunk/data/qcsrc/server/miscfunctions.qc
   trunk/data/qcsrc/server/progs.src
   trunk/data/qcsrc/server/sys.qh
Log:
new weapon arena menu controls, enjoy! Original code by MirceaKitsune


Modified: trunk/data/qcsrc/client/progs.src
===================================================================
--- trunk/data/qcsrc/client/progs.src	2008-11-09 07:20:21 UTC (rev 5021)
+++ trunk/data/qcsrc/client/progs.src	2008-11-09 10:11:56 UTC (rev 5022)
@@ -7,6 +7,7 @@
 ../common/constants.qh
 csqc_builtins.qc
 ../common/util.qh
+../common/items.qh
 
 ../common/mapinfo.qh
 interpolate.qh
@@ -37,3 +38,4 @@
 ../common/util.qc
 ../common/gamecommand.qc
 ../common/mapinfo.qc
+../common/items.qc

Modified: trunk/data/qcsrc/common/constants.qh
===================================================================
--- trunk/data/qcsrc/common/constants.qh	2008-11-09 07:20:21 UTC (rev 5021)
+++ trunk/data/qcsrc/common/constants.qh	2008-11-09 10:11:56 UTC (rev 5022)
@@ -298,56 +298,3 @@
 #define SP_SUICIDES 2
 #define SP_SCORE 3
 // game mode specific indices are not in common/, but in server/scores_rules.qc!
-
-// Weapon indexes
-// %weaponaddpoint
-float WEP_FIRST				=  1;
-float WEP_LASER				=  1; float WEPBIT_LASER			= 1; // always: 2^(w-1)
-float WEP_SHOTGUN			=  2; float WEPBIT_SHOTGUN			= 2;
-float WEP_UZI				=  3; float WEPBIT_UZI				= 4;
-float WEP_GRENADE_LAUNCHER	=  4; float WEPBIT_GRENADE_LAUNCHER	= 8;
-float WEP_ELECTRO			=  5; float WEPBIT_ELECTRO			= 16;
-float WEP_CRYLINK			=  6; float WEPBIT_CRYLINK			= 32;
-float WEP_NEX				=  7; float WEPBIT_NEX				= 64;
-float WEP_HAGAR				=  8; float WEPBIT_HAGAR			= 128;
-float WEP_ROCKET_LAUNCHER	=  9; float WEPBIT_ROCKET_LAUNCHER	= 256;
-float WEP_PORTO				= 10; float WEPBIT_PORTO			= 512;
-float WEP_MINSTANEX			= 11; float WEPBIT_MINSTANEX		= 1024;
-float WEP_HOOK     			= 12; float WEPBIT_HOOK     		= 2048;
-float WEP_HLAC			    = 13; float WEPBIT_HLAC		        = 4096;
-float WEP_SEEKER			= 14; float WEPBIT_SEEKER		    = 8192;
-float WEP_LAST				= 14; float WEPBIT_ALL              = 16383;
-float WEP_COUNT             = 15;
-
-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;
-// when this bit is set, using a superweapon does not throw it away. Checkpoints can give this powerup.
-float	IT_UNLIMITED_AMMO         = 3;
-// both of these combined
-float	IT_CTF_SHIELDED           = 4; // set for the flag shield
-float	IT_SHELLS				= 256;
-float	IT_NAILS				= 512;
-float	IT_ROCKETS				= 1024;
-float	IT_CELLS				= 2048;
-float	IT_SUPERWEAPON			= 4096;
-float	IT_AMMO					= 7936;
-float	IT_STRENGTH				= 8192;
-float	IT_INVINCIBLE			= 16384;
-float	IT_HEALTH				= 32768;
-// union:
-	// for items:
-	float	IT_KEY1					= 131072;
-	float	IT_KEY2					= 262144;
-	// for players:
-	float	IT_RED_FLAG_TAKEN		= 32768;
-	float	IT_RED_FLAG_LOST		= 65536;
-	float	IT_RED_FLAG_CARRING		= 98304;
-	float	IT_BLUE_FLAG_TAKEN		= 131072;
-	float	IT_BLUE_FLAG_LOST		= 262144;
-	float	IT_BLUE_FLAG_CARRING	= 393216;
-// end
-float	IT_5HP					= 524288;
-float	IT_25HP					= 1048576;
-float	IT_ARMOR_SHARD			= 2097152;
-float	IT_ARMOR				= 4194304;

Added: trunk/data/qcsrc/common/items.qc
===================================================================
--- trunk/data/qcsrc/common/items.qc	                        (rev 0)
+++ trunk/data/qcsrc/common/items.qc	2008-11-09 10:11:56 UTC (rev 5022)
@@ -0,0 +1,115 @@
+// WEAPON PLUGIN SYSTEM
+entity weapon_info[24];
+entity dummy_weapon_info;
+
+void register_weapon_real(float id, float(float) func, float ammotype, float i, float normalweapon, float canclimb, float pickupbasevalue, string modelname, string shortname, string wname)
+{
+	entity e;
+	weapon_info[id - 1] = e = spawn();
+	e.classname = "weapon_info";
+	e.weapon = id;
+	e.weapons = power2of(id - 1);
+	e.netname = shortname;
+	e.message = wname;
+	e.items = ammotype;
+	e.weapon_func = func;
+	e.mdl = modelname;
+	e.model = strzone(strcat("models/weapons/g_", modelname, ".md3"));
+	e.spawnflags = 0;
+	if(normalweapon)
+		e.spawnflags |= WEPSPAWNFLAG_NORMAL;
+	if(canclimb)
+		e.spawnflags |= WEPSPAWNFLAG_CANCLIMB;
+	e.impulse = i;
+	e.bot_pickupbasevalue = pickupbasevalue;
+}
+float w_null(float dummy)
+{
+	return 0;
+}
+void register_weapons_done()
+{
+	entity wi;
+
+	dummy_weapon_info = spawn();
+	dummy_weapon_info.classname = "weapon_info";
+	dummy_weapon_info.weapon = 0;
+	dummy_weapon_info.weapons = 0;
+	dummy_weapon_info.netname = "@!#%'n Tuba";
+	dummy_weapon_info.items = 0;
+	dummy_weapon_info.weapon_func = w_null;
+	dummy_weapon_info.mdl = "";
+	dummy_weapon_info.model = "";
+	dummy_weapon_info.spawnflags = 0;
+	dummy_weapon_info.impulse = -1;
+	dummy_weapon_info.bot_pickupbasevalue = 0;
+
+	float i;
+	weaponpriority_hudselector_0 = "";
+	for(i = 24; i >= 1; --i)
+		if(weapon_info[i-1])
+			weaponpriority_hudselector_0 = strcat(weaponpriority_hudselector_0, " ", ftos(i));
+
+	float imp;
+	weaponpriority_hudselector_1 = "";
+	for(i = 1; i <= 24; ++i)
+	{
+		wi = weapon_info[i-1];
+		if(wi && wi.impulse == 0)
+			weaponpriority_hudselector_1 = strcat(weaponpriority_hudselector_1, " ", ftos(i));
+	}
+	for(imp = 9; imp > 0; --imp)
+		for(i = 1; i <= 24; ++i)
+		{
+			wi = weapon_info[i-1];
+			if(wi && wi.impulse == imp)
+				weaponpriority_hudselector_1 = strcat(weaponpriority_hudselector_1, " ", ftos(i));
+		}
+
+	weaponpriority_hudselector_0 = strzone(substring(weaponpriority_hudselector_0, 1, strlen(weaponpriority_hudselector_0) - 1));
+	weaponpriority_hudselector_1 = strzone(substring(weaponpriority_hudselector_1, 1, strlen(weaponpriority_hudselector_1) - 1));
+}
+entity get_weaponinfo(float id)
+{
+	entity w;
+	if(id < WEP_FIRST || id > WEP_LAST)
+		return dummy_weapon_info;
+	w = weapon_info[id - 1];
+	if(w)
+		return w;
+	return dummy_weapon_info;
+}
+string W_FixWeaponOrder(string order, float complete)
+{
+	return fixPriorityList(order, WEP_FIRST, WEP_LAST, complete);
+}
+
+#ifdef SVQC
+#define register_weapon(id,func,ammotype,i,normalweapon,canclimb,pickupbasevalue,modelname,shortname,wname) \
+	register_weapon_real(id,func,ammotype,i,normalweapon,canclimb,pickupbasevalue,modelname,shortname,wname)
+#else
+// no weapon funcs here!
+#define register_weapon(id,func,ammotype,i,normalweapon,canclimb,pickupbasevalue,modelname,shortname,wname) \
+	register_weapon_real(id,w_null,ammotype,i,normalweapon,canclimb,pickupbasevalue,modelname,shortname,wname)
+#endif
+
+void RegisterWeapons()
+{
+	// %weaponaddpoint
+	register_weapon(WEP_LASER,            w_laser,     0,              1, 1, 1,     0, "laser",     "laser",           "Laser");
+	register_weapon(WEP_SHOTGUN,          w_shotgun,   IT_SHELLS,      2, 1, 0,  2500, "shotgun",   "shotgun",         "Shotgun");
+	register_weapon(WEP_UZI,              w_uzi,       IT_NAILS,       3, 1, 0,  5000, "uzi",       "uzi",             "Machine Gun");
+	register_weapon(WEP_GRENADE_LAUNCHER, w_glauncher, IT_ROCKETS,     4, 1, 1,  5000, "gl",        "grenadelauncher", "Mortar");
+	register_weapon(WEP_ELECTRO,          w_electro,   IT_CELLS,       5, 1, 0,  5000, "electro",   "electro",         "Electro");
+	register_weapon(WEP_CRYLINK,          w_crylink,   IT_CELLS,       6, 1, 0,  5000, "crylink",   "crylink",         "Crylink");
+	register_weapon(WEP_NEX,              w_nex,       IT_CELLS,       7, 1, 0, 10000, "nex",       "nex",             "Nex");
+	register_weapon(WEP_HAGAR,            w_hagar,     IT_ROCKETS,     8, 1, 1,  5000, "hagar",     "hagar",           "Hagar");
+	register_weapon(WEP_ROCKET_LAUNCHER,  w_rlauncher, IT_ROCKETS,     9, 1, 1, 10000, "rl",        "rocketlauncher",  "Rocket Launcher");
+	register_weapon(WEP_PORTO,            w_porto,     IT_SUPERWEAPON, 0, 0, 0,     0, "porto" ,    "porto",           "Port-O-Launch");
+	register_weapon(WEP_MINSTANEX,        w_minstanex, IT_CELLS,       7, 0, 1, 10000, "minstanex", "minstanex",       "MinstaNex");
+	register_weapon(WEP_HOOK,             w_hook,      IT_CELLS,       0, 0, 1,     0, "hookgun",   "hook",            "Grappling Hook");
+	register_weapon(WEP_SEEKER,           w_seeker,    IT_ROCKETS,     8, 1, 0,     0, "seeker",    "seeker",          "T.A.G. Seeker");
+	register_weapon(WEP_HLAC,             w_hlac,      IT_CELLS,       6, 1, 0,     0, "hlac",      "hlac",            "Heavy Laser Assault Cannon");
+
+	register_weapons_done();
+}

Added: trunk/data/qcsrc/common/items.qh
===================================================================
--- trunk/data/qcsrc/common/items.qh	                        (rev 0)
+++ trunk/data/qcsrc/common/items.qh	2008-11-09 10:11:56 UTC (rev 5022)
@@ -0,0 +1,77 @@
+// Weapon indexes
+// %weaponaddpoint
+float WEP_FIRST				=  1;
+float WEP_LASER				=  1; float WEPBIT_LASER			= 1; // always: 2^(w-1)
+float WEP_SHOTGUN			=  2; float WEPBIT_SHOTGUN			= 2;
+float WEP_UZI				=  3; float WEPBIT_UZI				= 4;
+float WEP_GRENADE_LAUNCHER	=  4; float WEPBIT_GRENADE_LAUNCHER	= 8;
+float WEP_ELECTRO			=  5; float WEPBIT_ELECTRO			= 16;
+float WEP_CRYLINK			=  6; float WEPBIT_CRYLINK			= 32;
+float WEP_NEX				=  7; float WEPBIT_NEX				= 64;
+float WEP_HAGAR				=  8; float WEPBIT_HAGAR			= 128;
+float WEP_ROCKET_LAUNCHER	=  9; float WEPBIT_ROCKET_LAUNCHER	= 256;
+float WEP_PORTO				= 10; float WEPBIT_PORTO			= 512;
+float WEP_MINSTANEX			= 11; float WEPBIT_MINSTANEX		= 1024;
+float WEP_HOOK     			= 12; float WEPBIT_HOOK     		= 2048;
+float WEP_HLAC			    = 13; float WEPBIT_HLAC		        = 4096;
+float WEP_SEEKER			= 14; float WEPBIT_SEEKER		    = 8192;
+float WEP_LAST				= 14; float WEPBIT_ALL              = 16383;
+float WEP_COUNT             = 15;
+
+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;
+// when this bit is set, using a superweapon does not throw it away. Checkpoints can give this powerup.
+float	IT_UNLIMITED_AMMO         = 3;
+// both of these combined
+float	IT_CTF_SHIELDED           = 4; // set for the flag shield
+float	IT_SHELLS				= 256;
+float	IT_NAILS				= 512;
+float	IT_ROCKETS				= 1024;
+float	IT_CELLS				= 2048;
+float	IT_SUPERWEAPON			= 4096;
+float	IT_AMMO					= 7936;
+float	IT_STRENGTH				= 8192;
+float	IT_INVINCIBLE			= 16384;
+float	IT_HEALTH				= 32768;
+// union:
+	// for items:
+	float	IT_KEY1					= 131072;
+	float	IT_KEY2					= 262144;
+	// for players:
+	float	IT_RED_FLAG_TAKEN		= 32768;
+	float	IT_RED_FLAG_LOST		= 65536;
+	float	IT_RED_FLAG_CARRING		= 98304;
+	float	IT_BLUE_FLAG_TAKEN		= 131072;
+	float	IT_BLUE_FLAG_LOST		= 262144;
+	float	IT_BLUE_FLAG_CARRING	= 393216;
+// end
+float	IT_5HP					= 524288;
+float	IT_25HP					= 1048576;
+float	IT_ARMOR_SHARD			= 2097152;
+float	IT_ARMOR				= 4194304;
+
+// variables:
+string weaponpriority_hudselector_0;
+string weaponpriority_hudselector_1;
+
+// functions:
+entity get_weaponinfo(float id);
+string W_FixWeaponOrder(string order, float complete);
+void RegisterWeapons();
+
+#define WEPSPAWNFLAG_NORMAL 1
+#define WEPSPAWNFLAG_CANCLIMB 2
+
+// entity properties of weaponinfo:
+.float weapon; // WEP_...
+.float weapons; // WEPBIT_...
+.string netname; // short name
+.string message; // human readable name
+.float items; // IT_...
+.float(float) weapon_func; // w_...
+.string mdl; // modelname without g_, v_, w_
+.string model; // full name of g_ model
+.float spawnflags; // WEPSPAWNFLAG_... combined
+.float impulse; // weapon impulse
+.float bot_pickupbasevalue; // bot weapon priority

Modified: trunk/data/qcsrc/common/util.qc
===================================================================
--- trunk/data/qcsrc/common/util.qc	2008-11-09 07:20:21 UTC (rev 5021)
+++ trunk/data/qcsrc/common/util.qc	2008-11-09 10:11:56 UTC (rev 5022)
@@ -1052,3 +1052,82 @@
 	argv_end_index = func_null;
 	return _tokenizebyseparator_builtin(s, sep);
 }
+
+float power2of(float e)
+{
+	return pow(2, e);
+}
+float log2of(float x)
+{
+	// NOTE: generated code
+	if(x > 2048)
+		if(x > 131072)
+			if(x > 1048576)
+				if(x > 4194304)
+					return 23;
+				else
+					if(x > 2097152)
+						return 22;
+					else
+						return 21;
+			else
+				if(x > 524288)
+					return 20;
+				else
+					if(x > 262144)
+						return 19;
+					else
+						return 18;
+		else
+			if(x > 16384)
+				if(x > 65536)
+					return 17;
+				else
+					if(x > 32768)
+						return 16;
+					else
+						return 15;
+			else
+				if(x > 8192)
+					return 14;
+				else
+					if(x > 4096)
+						return 13;
+					else
+						return 12;
+	else
+		if(x > 32)
+			if(x > 256)
+				if(x > 1024)
+					return 11;
+				else
+					if(x > 512)
+						return 10;
+					else
+						return 9;
+			else
+				if(x > 128)
+					return 8;
+				else
+					if(x > 64)
+						return 7;
+					else
+						return 6;
+		else
+			if(x > 4)
+				if(x > 16)
+					return 5;
+				else
+					if(x > 8)
+						return 4;
+					else
+						return 3;
+			else
+				if(x > 2)
+					return 2;
+				else
+					if(x > 1)
+						return 1;
+					else
+						return 0;
+}

Modified: trunk/data/qcsrc/common/util.qh
===================================================================
--- trunk/data/qcsrc/common/util.qh	2008-11-09 07:20:21 UTC (rev 5021)
+++ trunk/data/qcsrc/common/util.qh	2008-11-09 10:11:56 UTC (rev 5022)
@@ -116,3 +116,6 @@
 float tokenize_sane(string s);
 float tokenize_insane(string s);
 float tokenizebyseparator(string s, string sep);
+
+float power2of(float e);
+float log2of(float x);

Modified: trunk/data/qcsrc/menu/menu.qc
===================================================================
--- trunk/data/qcsrc/menu/menu.qc	2008-11-09 07:20:21 UTC (rev 5021)
+++ trunk/data/qcsrc/menu/menu.qc	2008-11-09 10:11:56 UTC (rev 5022)
@@ -63,6 +63,8 @@
 	menuInitialized = 1;
 	GameCommand_Init();
 
+	RegisterWeapons();
+
 	fh = -1;
 	if(cvar_string("menu_skin") != "")
 	{

Modified: trunk/data/qcsrc/menu/nexuiz/dialog_multiplayer_create_mutators.c
===================================================================
--- trunk/data/qcsrc/menu/nexuiz/dialog_multiplayer_create_mutators.c	2008-11-09 07:20:21 UTC (rev 5021)
+++ trunk/data/qcsrc/menu/nexuiz/dialog_multiplayer_create_mutators.c	2008-11-09 10:11:56 UTC (rev 5022)
@@ -6,9 +6,9 @@
 	METHOD(NexuizMutatorsDialog, close, void(entity))
 	ATTRIB(NexuizMutatorsDialog, title, string, "Mutators")
 	ATTRIB(NexuizMutatorsDialog, color, vector, SKINCOLOR_DIALOG_MUTATORS)
-	ATTRIB(NexuizMutatorsDialog, intendedWidth, float, 0.6)
-	ATTRIB(NexuizMutatorsDialog, rows, float, 9)
-	ATTRIB(NexuizMutatorsDialog, columns, float, 4)
+	ATTRIB(NexuizMutatorsDialog, intendedWidth, float, 0.8)
+	ATTRIB(NexuizMutatorsDialog, rows, float, 16)
+	ATTRIB(NexuizMutatorsDialog, columns, float, 6)
 	ATTRIB(NexuizMutatorsDialog, refilterEntity, entity, NULL)
 ENDCLASS(NexuizMutatorsDialog)
 #endif
@@ -16,8 +16,50 @@
 #ifdef IMPLEMENTATION
 void showNotifyNexuizMutatorsDialog(entity me)
 {
-        loadAllCvars(me);
+	loadAllCvars(me);
 }
+
+string weaponarenastring;
+string weaponarenastring_cvar;
+string WeaponArenaString()
+{
+	string s;
+	float n, i, j;
+	entity e;
+	s = cvar_string("g_weaponarena");
+	if(s == "0")
+		return "";
+	if(s == "all")
+		return "All Weapons Arena";
+	if(s == "most")
+		return "Most Weapons Arena";
+	if(s == weaponarenastring_cvar)
+		return weaponarenastring;
+	if(weaponarenastring)
+		strunzone(weaponarenastring);
+	if(weaponarenastring_cvar)
+		strunzone(weaponarenastring_cvar);
+
+	weaponarenastring_cvar = strzone(s);
+
+	n = tokenize_sane(s);
+	s = "";
+	for(i = 0; i < n; ++i)
+	{
+		for(j = WEP_FIRST; j <= WEP_LAST; ++j)
+		{
+			e = get_weaponinfo(j);
+			if(argv(i) == e.netname)
+				s = strcat(s, " & ", e.message);
+		}
+	}
+	s = strcat(substring(s, 3, strlen(s) - 3), " Arena");
+	
+	weaponarenastring = strzone(s);
+
+	return weaponarenastring;
+}
+
 string toStringNexuizMutatorsDialog(entity me)
 {
 	string s;
@@ -27,7 +69,7 @@
 	if(cvar("g_nixnex"))
 		s = strcat(s, ", NixNex");
 	if(cvar_string("g_weaponarena") != "0")
-		s = strcat(s, ", ", cvar_string("g_weaponarena"), " arena");
+		s = strcat(s, ", ", WeaponArenaString());
 	if(cvar("sv_gravity") < 800)
 		s = strcat(s, ", Low gravity");
 	if(cvar("g_cloaked"))
@@ -49,7 +91,9 @@
 }
 void fillNexuizMutatorsDialog(entity me)
 {
-	entity e, s;
+	entity e, s, w;
+	float i, j;
+	string str, hstr;
 	me.TR(me);
 		me.TD(me, 1, 2, makeNexuizTextLabel(0, "Game mutators:"));
 	me.TR(me);
@@ -66,19 +110,36 @@
 		me.TD(me, 1, 2, e = makeNexuizCheckBox(0, "g_vampire", "Vampire"));
 
 	me.gotoRC(me, 0, 2); me.setFirstColumn(me, me.currentColumn);
-		me.TD(me, 1, 2, makeNexuizTextLabel(0, "Arena mutators:"));
+		me.TD(me, 1, 4, makeNexuizTextLabel(0, "Weapon arenas:"));
 	me.TR(me);
-		me.TD(me, 1, 2, e = makeNexuizRadioButton(1, string_null, string_null, "Regular"));
+		me.TD(me, 1, 4, e = makeNexuizRadioButton(1, string_null, string_null, "Regular (no arena)"));
+	for(i = WEP_FIRST, j = 0; i <= WEP_LAST; ++i, ++j)
+	{
+		w = get_weaponinfo(i);
+		if(j & 1 == 0)
+			me.TR(me);
+		str = w.netname;
+		hstr = w.message;
+		if not(w.spawnflags & WEPSPAWNFLAG_CANCLIMB)
+		{
+			str = strcat(str, " laser");
+			hstr = strcat(hstr, " & Laser");
+		}
+		me.TD(me, 1, 2, e = makeNexuizRadioButton(1, "g_weaponarena", strzone(str), strzone(hstr)));
+			e.cvarOffValue = "0";
+	}
 	me.TR(me);
-		me.TD(me, 1, 2, e = makeNexuizRadioButton(1, "g_minstagib", string_null, "MinstaGib"));
+		me.TD(me, 1, 4, makeNexuizTextLabel(0, "Special arenas:"));
 	me.TR(me);
-		me.TD(me, 1, 2, e = makeNexuizRadioButton(1, "g_nixnex", string_null, "NixNex"));
+		me.TD(me, 1, 4, e = makeNexuizRadioButton(1, "g_minstagib", string_null, "MinstaGib"));
 	me.TR(me);
+		me.TD(me, 1, 4, e = makeNexuizRadioButton(1, "g_nixnex", string_null, "NixNex"));
+	me.TR(me);
 		me.TDempty(me, 0.2);
-		me.TD(me, 1, 1.8, e = makeNexuizCheckBox(1, "g_nixnex_with_laser", "with laser"));
+		me.TD(me, 1, 3.8, e = makeNexuizCheckBox(1, "g_nixnex_with_laser", "with laser"));
 			setDependent(e, "g_nixnex", 1, 1);
 	me.TR(me);
-		me.TD(me, 1, 2, e = makeNexuizRadioButton(1, "g_weaponarena", "rocketlauncher", "Rocket launcher arena"));
+		me.TD(me, 1, 4, e = makeNexuizRadioButton(1, "g_weaponarena", "all", "All weapons"));
 			e.cvarOffValue = "0";
 
 	me.gotoRC(me, me.rows - 2, 0);
@@ -87,7 +148,7 @@
 			s.valueDisplayMultiplier = 0.125; // show gravity in percent
 		me.TD(me, 1, 1, e = makeNexuizSliderCheckBox(800, 1, s, "Low gravity"));
 			e.savedValue = 200; // good on silvercity
-		me.TD(me, 1, 3, s);
+		me.TD(me, 1, 5, s);
 
 	me.gotoRC(me, me.rows - 1, 0);
 		me.TD(me, 1, me.columns, e = makeNexuizButton("OK", '0 0 0'));

Modified: trunk/data/qcsrc/menu/nexuiz/weaponslist.c
===================================================================
--- trunk/data/qcsrc/menu/nexuiz/weaponslist.c	2008-11-09 07:20:21 UTC (rev 5021)
+++ trunk/data/qcsrc/menu/nexuiz/weaponslist.c	2008-11-09 10:11:56 UTC (rev 5022)
@@ -76,43 +76,27 @@
 		cvar_set("cl_weaponpriority", swapInPriorityList(cvar_string("cl_weaponpriority"), me.selectedItem, i));
 	return f;
 }
-string WeaponName(float w)
-{
-	switch(w)
-	{
-		//%weaponaddpoint
-		case WEP_LASER:            return "Laser";
-		case WEP_SHOTGUN:          return "Shotgun";
-		case WEP_UZI:              return "Machine Gun";
-		case WEP_GRENADE_LAUNCHER: return "Mortar";
-		case WEP_ELECTRO:          return "Electro";
-		case WEP_CRYLINK:          return "Crylink";
-		case WEP_NEX:              return "Nex";
-		case WEP_HAGAR:            return "Hagar";
-		case WEP_ROCKET_LAUNCHER:  return "Rocket Launcher";
-		case WEP_PORTO:            return "Port-O-Launch";
-		case WEP_MINSTANEX:        return "MinstaNex";
-		case WEP_HOOK:             return "Grappling Hook";
-		case WEP_HLAC:             return "Heavy Laser Assault Cannon";
-		case WEP_SEEKER:           return "T.A.G. Seeker";
-		default:                   return "(fix qcsrc/menu/nexuiz/weaponslist.c)";
-	}
-}
 string toStringNexuizWeaponsList(entity me)
 {
 	float n, i;
 	string s;
+	entity e;
 	n = tokenize_sane(cvar_string("cl_weaponpriority"));
 	s = "";
 	for(i = 0; i < n; ++i)
-		s = strcat(s, WeaponName(stof(argv(i))), ", ");
+	{
+		e = get_weaponinfo(stof(argv(i)));
+		s = strcat(s, e.message, ", ");
+	}
 	return substring(s, 0, strlen(s) - 2);
 }
 void drawListBoxItemNexuizWeaponsList(entity me, float i, vector absSize, float isSelected)
 {
+	entity e;
 	if(isSelected)
 		draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
-	draw_Text(me.realUpperMargin * eY, WeaponName(stof(argv(i))), me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
+	e = get_weaponinfo(stof(argv(i)));
+	draw_Text(me.realUpperMargin * eY, e.message, me.realFontSize, '1 1 1', SKINALPHA_TEXT, 0);
 }
 
 float keyDownNexuizWeaponsList(entity me, float scan, float ascii, float shift)

Modified: trunk/data/qcsrc/menu/progs.src
===================================================================
--- trunk/data/qcsrc/menu/progs.src	2008-11-09 07:20:21 UTC (rev 5021)
+++ trunk/data/qcsrc/menu/progs.src	2008-11-09 10:11:56 UTC (rev 5022)
@@ -11,6 +11,7 @@
 ../common/constants.qh
 ../common/mapinfo.qh
 ../common/campaign_common.qh
+../common/items.qh
 
 gamecommand.qh
 menu.qh
@@ -36,3 +37,4 @@
 ../common/campaign_file.qc
 ../common/campaign_setup.qc
 ../common/mapinfo.qc
+../common/items.qc

Modified: trunk/data/qcsrc/server/cl_weapons.qc
===================================================================
--- trunk/data/qcsrc/server/cl_weapons.qc	2008-11-09 07:20:21 UTC (rev 5021)
+++ trunk/data/qcsrc/server/cl_weapons.qc	2008-11-09 10:11:56 UTC (rev 5022)
@@ -102,11 +102,6 @@
 		W_CycleWeapon(self.cvar_cl_weaponpriority, +1);
 }
 
-string W_FixWeaponOrder(string order, float complete)
-{
-	return fixPriorityList(order, WEP_FIRST, WEP_LAST, complete);
-}
-
 string W_FixWeaponOrder_AllowIncomplete(string order)
 {
 	return W_FixWeaponOrder(order, 0);
@@ -448,24 +443,3 @@
 					W_SwitchWeapon(nixnex_weapon);
 	}
 }
-
-void RegisterWeapons()
-{
-	// %weaponaddpoint
-	register_weapon(WEP_LASER,            w_laser,     0,              1, 1,     0, "laser",     "laser",           "Laser");
-	register_weapon(WEP_SHOTGUN,          w_shotgun,   IT_SHELLS,      2, 1,  2500, "shotgun",   "shotgun",         "Shotgun");
-	register_weapon(WEP_UZI,              w_uzi,       IT_NAILS,       3, 1,  5000, "uzi",       "uzi",             "Machine Gun");
-	register_weapon(WEP_GRENADE_LAUNCHER, w_glauncher, IT_ROCKETS,     4, 1,  5000, "gl",        "grenadelauncher", "Mortar");
-	register_weapon(WEP_ELECTRO,          w_electro,   IT_CELLS,       5, 1,  5000, "electro",   "electro",         "Electro");
-	register_weapon(WEP_CRYLINK,          w_crylink,   IT_CELLS,       6, 1,  5000, "crylink",   "crylink",         "Crylink");
-	register_weapon(WEP_NEX,              w_nex,       IT_CELLS,       7, 1, 10000, "nex",       "nex",             "Nex");
-	register_weapon(WEP_HAGAR,            w_hagar,     IT_ROCKETS,     8, 1,  5000, "hagar",     "hagar",           "Hagar");
-	register_weapon(WEP_ROCKET_LAUNCHER,  w_rlauncher, IT_ROCKETS,     9, 1, 10000, "rl",        "rocketlauncher",  "Rocket Launcher");
-	register_weapon(WEP_PORTO,            w_porto,     IT_SUPERWEAPON, 0, 0,     0, "porto" ,    "porto",           "Port-O-Launch");
-	register_weapon(WEP_MINSTANEX,        w_minstanex, IT_CELLS,       7, 0, 10000, "minstanex", "minstanex",       "MinstaNex");
-	register_weapon(WEP_HOOK,             w_hook,      IT_CELLS,       0, 0,     0, "hookgun",   "hook",            "Grappling Hook");
-	register_weapon(WEP_SEEKER,           w_seeker,    IT_ROCKETS,     8, 1,     0, "seeker",    "seeker",          "T.A.G. Seeker");
-	register_weapon(WEP_HLAC,             w_hlac,      IT_CELLS,       6, 1,     0, "hlac",      "hlac",            "Heavy Laser Assault Cannon");
-
-	register_weapons_done();
-}

Modified: trunk/data/qcsrc/server/cl_weaponsystem.qc
===================================================================
--- trunk/data/qcsrc/server/cl_weaponsystem.qc	2008-11-09 07:20:21 UTC (rev 5021)
+++ trunk/data/qcsrc/server/cl_weaponsystem.qc	2008-11-09 10:11:56 UTC (rev 5022)
@@ -637,85 +637,3 @@
 
 	missile.velocity = W_CalculateProjectileVelocity(missile.owner.velocity, missile.velocity);
 }
-
-
-// WEAPON PLUGIN SYSTEM
-entity weapon_info[24];
-entity dummy_weapon_info;
-.float(float) weapon_func;
-string weaponpriority_hudselector_0;
-string weaponpriority_hudselector_1;
-
-void register_weapon(float id, float(float) func, float ammotype, float i, float normalweapon, float pickupbasevalue, string modelname, string shortname, string name)
-{
-	entity e;
-	weapon_info[id - 1] = e = spawn();
-	e.classname = "weapon_info";
-	e.weapon = id;
-	e.weapons = power2of(id - 1);
-	e.netname = shortname;
-	e.message = name;
-	e.items = ammotype;
-	e.weapon_func = func;
-	e.mdl = modelname;
-	e.model = strzone(strcat("models/weapons/g_", modelname, ".md3"));
-	e.spawnflags = normalweapon;
-	e.impulse = i;
-	e.bot_pickupbasevalue = pickupbasevalue;
-}
-float w_null(float dummy)
-{
-	return 0;
-}
-void register_weapons_done()
-{
-	entity wi;
-
-	dummy_weapon_info = spawn();
-	dummy_weapon_info.classname = "weapon_info";
-	dummy_weapon_info.weapon = 0;
-	dummy_weapon_info.weapons = 0;
-	dummy_weapon_info.netname = "@!#%'n Tuba";
-	dummy_weapon_info.items = 0;
-	dummy_weapon_info.weapon_func = w_null;
-	dummy_weapon_info.mdl = "";
-	dummy_weapon_info.model = "";
-	dummy_weapon_info.spawnflags = 0;
-	dummy_weapon_info.impulse = -1;
-	dummy_weapon_info.bot_pickupbasevalue = 0;
-
-	float i;
-	weaponpriority_hudselector_0 = "";
-	for(i = 24; i >= 1; --i)
-		if(weapon_info[i-1])
-			weaponpriority_hudselector_0 = strcat(weaponpriority_hudselector_0, " ", ftos(i));
-
-	float imp;
-	weaponpriority_hudselector_1 = "";
-	for(i = 1; i <= 24; ++i)
-	{
-		wi = weapon_info[i-1];
-		if(wi && wi.impulse == 0)
-			weaponpriority_hudselector_1 = strcat(weaponpriority_hudselector_1, " ", ftos(i));
-	}
-	for(imp = 9; imp > 0; --imp)
-		for(i = 1; i <= 24; ++i)
-		{
-			wi = weapon_info[i-1];
-			if(wi && wi.impulse == imp)
-				weaponpriority_hudselector_1 = strcat(weaponpriority_hudselector_1, " ", ftos(i));
-		}
-
-	weaponpriority_hudselector_0 = strzone(substring(weaponpriority_hudselector_0, 1, strlen(weaponpriority_hudselector_0) - 1));
-	weaponpriority_hudselector_1 = strzone(substring(weaponpriority_hudselector_1, 1, strlen(weaponpriority_hudselector_1) - 1));
-}
-entity get_weaponinfo(float id)
-{
-	entity w;
-	if(id < WEP_FIRST || id > WEP_LAST)
-		return dummy_weapon_info;
-	w = weapon_info[id - 1];
-	if(w)
-		return w;
-	return dummy_weapon_info;
-}

Modified: trunk/data/qcsrc/server/miscfunctions.qc
===================================================================
--- trunk/data/qcsrc/server/miscfunctions.qc	2008-11-09 07:20:21 UTC (rev 5021)
+++ trunk/data/qcsrc/server/miscfunctions.qc	2008-11-09 10:11:56 UTC (rev 5022)
@@ -772,7 +772,7 @@
 		for(j = WEP_FIRST; j <= WEP_LAST; ++j)
 		{
 			e = get_weaponinfo(j);
-			if(e.spawnflags & 1)
+			if(e.spawnflags & WEPSPAWNFLAG_NORMAL)
 			{
 				g_weaponarena |= e.weapons;
 				weapon_action(e.weapon, WR_PRECACHE);
@@ -863,7 +863,7 @@
 			e = get_weaponinfo(i);
 			if(!(e.weapon))
 				continue;
-			if(((e.spawnflags & 1) && g_lms) || cvar(strcat("g_start_weapon_", e.netname)))
+			if(((e.spawnflags & WEPSPAWNFLAG_NORMAL) && g_lms) || cvar(strcat("g_start_weapon_", e.netname)))
 			{
 				start_weapons |= e.weapons;
 				weapon_action(e.weapon, WR_PRECACHE);
@@ -899,7 +899,7 @@
 					e = get_weaponinfo(i);
 					if(!(e.weapon))
 						continue;
-					if(e.spawnflags & 1)
+					if(e.spawnflags & WEPSPAWNFLAG_NORMAL)
 					{
 						warmup_start_weapons |= e.weapons;
 						weapon_action(e.weapon, WR_PRECACHE);
@@ -1454,85 +1454,6 @@
 .float nottargeted;
 #define IFTARGETED if(!self.nottargeted && self.targetname != "")
 
-float power2of(float e)
-{
-	return pow(2, e);
-}
-float log2of(float x)
-{
-	// NOTE: generated code
-	if(x > 2048)
-		if(x > 131072)
-			if(x > 1048576)
-				if(x > 4194304)
-					return 23;
-				else
-					if(x > 2097152)
-						return 22;
-					else
-						return 21;
-			else
-				if(x > 524288)
-					return 20;
-				else
-					if(x > 262144)
-						return 19;
-					else
-						return 18;
-		else
-			if(x > 16384)
-				if(x > 65536)
-					return 17;
-				else
-					if(x > 32768)
-						return 16;
-					else
-						return 15;
-			else
-				if(x > 8192)
-					return 14;
-				else
-					if(x > 4096)
-						return 13;
-					else
-						return 12;
-	else
-		if(x > 32)
-			if(x > 256)
-				if(x > 1024)
-					return 11;
-				else
-					if(x > 512)
-						return 10;
-					else
-						return 9;
-			else
-				if(x > 128)
-					return 8;
-				else
-					if(x > 64)
-						return 7;
-					else
-						return 6;
-		else
-			if(x > 4)
-				if(x > 16)
-					return 5;
-				else
-					if(x > 8)
-						return 4;
-					else
-						return 3;
-			else
-				if(x > 2)
-					return 2;
-				else
-					if(x > 1)
-						return 1;
-					else
-						return 0;
-}
-
 void Net_LinkEntity(entity e)
 {
 	e.model = "net_entity";

Modified: trunk/data/qcsrc/server/progs.src
===================================================================
--- trunk/data/qcsrc/server/progs.src	2008-11-09 07:20:21 UTC (rev 5021)
+++ trunk/data/qcsrc/server/progs.src	2008-11-09 10:11:56 UTC (rev 5022)
@@ -3,12 +3,14 @@
 ../common/util-pre.qh
 sys.qh
 builtins.qh
+extensions.qh
 constants.qh
 ../common/constants.qh
-defs.qh		// Should rename this, it has fields and globals
-extensions.qh
 ../common/util.qh
+../common/items.qh
 
+defs.qh		// Should rename this, it has fields and globals
+
 //// tZork Turrets ////
 tturrets/include/turrets_early.qh
 
@@ -152,3 +154,5 @@
 
 target_spawn.qc
 func_breakable.qc
+
+../common/items.qc

Modified: trunk/data/qcsrc/server/sys.qh
===================================================================
--- trunk/data/qcsrc/server/sys.qh	2008-11-09 07:20:21 UTC (rev 5021)
+++ trunk/data/qcsrc/server/sys.qh	2008-11-09 10:11:56 UTC (rev 5022)
@@ -1,4 +1,5 @@
 #pragma flag off fastarrays // make dp behave with new fteqcc versions. remove when dp bug with fteqcc fastarrays is fixed
+#define SVQC
 
 // DO NOT modify the contents of this file, or you will risk incompatibility with the game engine.
 




More information about the nexuiz-commits mailing list