r4564 - in trunk/data: maps qcsrc/client qcsrc/common qcsrc/menu qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Wed Oct 1 02:06:25 EDT 2008


Author: div0
Date: 2008-10-01 02:06:25 -0400 (Wed, 01 Oct 2008)
New Revision: 4564

Removed:
   trunk/data/maps/ons-reborn.info
Modified:
   trunk/data/maps/ons-reborn.mapinfo
   trunk/data/qcsrc/client/Defs.qc
   trunk/data/qcsrc/client/Main.qc
   trunk/data/qcsrc/client/View.qc
   trunk/data/qcsrc/client/csqc_builtins.qc
   trunk/data/qcsrc/client/laser.qc
   trunk/data/qcsrc/client/progs.src
   trunk/data/qcsrc/common/mapinfo.qc
   trunk/data/qcsrc/common/mapinfo.qh
   trunk/data/qcsrc/common/util.qc
   trunk/data/qcsrc/common/util.qh
   trunk/data/qcsrc/menu/progs.src
   trunk/data/qcsrc/server/gamecommand.qc
   trunk/data/qcsrc/server/progs.src
Log:
get rid of .info files; make interpolation generic


Deleted: trunk/data/maps/ons-reborn.info
===================================================================
--- trunk/data/maps/ons-reborn.info	2008-09-30 18:31:39 UTC (rev 4563)
+++ trunk/data/maps/ons-reborn.info	2008-10-01 06:06:25 UTC (rev 4564)
@@ -1,8 +0,0 @@
-// This file is necessary if world.mins/maxs is wrong.
-// It happens when q3map2 fucks up, or you put entities far outside the map,
-// like ons-reborn the trains.
-// Every unrecognized line in this file will be printed to the console
-// unless it begins with double slashes
-// This is a sample file =)
-mins -8224.0 -8224.0 -96.0
-maxs 8224.0 8224.0 6496.0

Modified: trunk/data/maps/ons-reborn.mapinfo
===================================================================
--- trunk/data/maps/ons-reborn.mapinfo	2008-09-30 18:31:39 UTC (rev 4563)
+++ trunk/data/maps/ons-reborn.mapinfo	2008-10-01 06:06:25 UTC (rev 4564)
@@ -6,3 +6,4 @@
 has weapons
 type ons 20
 cdtrack 8
+size -8224.0 -8224.0 -96.0 8224.0 8224.0 6496.0

Modified: trunk/data/qcsrc/client/Defs.qc
===================================================================
--- trunk/data/qcsrc/client/Defs.qc	2008-09-30 18:31:39 UTC (rev 4563)
+++ trunk/data/qcsrc/client/Defs.qc	2008-10-01 06:06:25 UTC (rev 4564)
@@ -175,7 +175,6 @@
 float vid_conwidth, vid_conheight;
 float configdb;
 float binddb;
-string shortmapname;
 
 // QUALIFYING
 float race_checkpoint;
@@ -203,3 +202,6 @@
 
 // Spectating
 float spectatee_status;
+
+// short mapname
+string shortmapname;

Modified: trunk/data/qcsrc/client/Main.qc
===================================================================
--- trunk/data/qcsrc/client/Main.qc	2008-09-30 18:31:39 UTC (rev 4563)
+++ trunk/data/qcsrc/client/Main.qc	2008-10-01 06:06:25 UTC (rev 4564)
@@ -4,7 +4,7 @@
 
 #define DP_CSQC_ENTITY_REMOVE_IS_B0RKED
 
-void cvar_settemp(string cv, string val)
+void cvar_clientsettemp(string cv, string val)
 {
 	entity e;
 	for(e = world; (e = find(e, classname, "saved_cvar_value")); )
@@ -18,7 +18,7 @@
 	cvar_set(cv, val);
 }
 
-void cvar_settemp_restore()
+void cvar_clientsettemp_restore()
 {
 	entity e;
 	for(e = world; (e = find(e, classname, "saved_cvar_value")); )
@@ -113,7 +113,7 @@
 	
 	GetTeam(COLOR_SPECTATOR, true); // add specs first
 
-	cvar_settemp("_supports_weaponpriority", "1");
+	cvar_clientsettemp("_supports_weaponpriority", "1");
 }
 
 // CSQC_Shutdown : Called every time the CSQC code is shutdown (changing maps, quitting, etc)
@@ -131,7 +131,7 @@
 	db_close(configdb);
 	db_close(binddb);
 
-	cvar_settemp_restore();
+	cvar_clientsettemp_restore();
 }
 
 .float has_team;
@@ -297,7 +297,7 @@
 		return true;
 	}
 	else if(cmd == "settemp") {
-		cvar_settemp(argv(1), argv(2));
+		cvar_clientsettemp(argv(1), argv(2));
 	}
 	
 	return false;
@@ -572,46 +572,14 @@
 	local string mapinfo, infoline;
 	local float len;
 	local float file;
-	local vector mi_min, mi_max;
 
-	if(!strcasecmp(substring(mapname, 0, 5), "maps/"))
-		shortmapname = substring(mapname, 5, 999);
-	else
-		shortmapname = mapname;
-	len = strlen(shortmapname);
-	if(!strcasecmp(substring(shortmapname, len-4, 4), ".bsp"))
-		shortmapname = substring(shortmapname, 0, len-4);
-	shortmapname = strzone(shortmapname);
+	get_mi_min_max();
+	mi_center = (mi_min + mi_max) * 0.5;
+	mi_scale = mi_max - mi_min;
+	minimapname = strzone(strcat("gfx/", mi_shortname, "_mini.tga"));
+	shortmapname = mi_shortname;
 
 	if(gametype == GAME_ONSLAUGHT) {
-		mapinfo = strcat("maps/", minimapname, ".info");
-		minimapname = strzone(strcat("gfx/", shortmapname, "_mini.tga"));
-
-		mi_min = world.mins;
-		mi_max = world.maxs;
-		
-		file = fopen(mapinfo, FILE_READ);
-		if(file >= 0) {
-			while((infoline = fgets(file))) {
-				if(!strncasecmp(infoline, "mins", 4)) {
-					mi_min = stov(substring(infoline, 5, 999));
-				} else if(!strncasecmp(infoline, "maxs", 4)) {
-					mi_max = stov(substring(infoline, 5, 999));
-				} else if(strncasecmp(infoline, "//", 2)) { // don't print comment-style lines
-					print(strcat("mapinfo: ", infoline, "\n"));
-				}
-			}
-		} else {
-			print(strcat("Map has no .info file (", mapinfo, ").\n"));
-		}
-		fclose(file);
-
-		print(strcat("Mins: ", vtos(mi_min), "    Maxs: ", vtos(mi_max), "\n"));
-		
-		mi_center = (mi_min + mi_max) * 0.5;
-		mi_scale = mi_max - mi_min;
-		
-		
 		print(strcat("Using ", minimapname, " as minimap.\n"));
 		precache_pic(minimapname);
 		precache_pic("gfx/ons-cp-neutral.tga");

Modified: trunk/data/qcsrc/client/View.qc
===================================================================
--- trunk/data/qcsrc/client/View.qc	2008-09-30 18:31:39 UTC (rev 4563)
+++ trunk/data/qcsrc/client/View.qc	2008-10-01 06:06:25 UTC (rev 4564)
@@ -58,7 +58,7 @@
 		if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP)
 			continue;
 		++portal_number;
-		ang = vectoangles(trace_plane_normal, dir);
+		ang = vectoangles2(trace_plane_normal, dir);
 		ang_x = -ang_x;
 		makevectors(ang);
 		if(!CheckWireframeBox(porto, p - 48 * v_right - 48 * v_up + 16 * v_forward, 96 * v_right, 96 * v_up, 96 * v_forward))

Modified: trunk/data/qcsrc/client/csqc_builtins.qc
===================================================================
--- trunk/data/qcsrc/client/csqc_builtins.qc	2008-09-30 18:31:39 UTC (rev 4563)
+++ trunk/data/qcsrc/client/csqc_builtins.qc	2008-10-01 06:06:25 UTC (rev 4564)
@@ -39,7 +39,8 @@
 void (string s, ...)							localcmd = #46;
 entity (entity e)							nextent = #47;
 
-vector (vector v, ...)							vectoangles = #51;
+vector (vector v)							vectoangles = #51;
+vector (vector v, vector w)							vectoangles2 = #51;
 
 void (string var, string val)						cvar_set = #72;
 

Modified: trunk/data/qcsrc/client/laser.qc
===================================================================
--- trunk/data/qcsrc/client/laser.qc	2008-09-30 18:31:39 UTC (rev 4563)
+++ trunk/data/qcsrc/client/laser.qc	2008-10-01 06:06:25 UTC (rev 4564)
@@ -1,75 +1,3 @@
-// FIXME make this generic code, to be used for other entities too?
-.vector iorigin1, iorigin2;
-.vector ivelocity1, ivelocity2;
-.vector iforward1, iforward2;
-.vector iright1, iright2;
-.float itime1, itime2;
-void InterpolateOrigin_Note()
-{
-	float dt;
-
-	makevectors(self.angles);
-
-	self.iorigin1 = self.iorigin2;
-	self.iforward1 = self.iforward2;
-	self.iright1 = self.iright2;
-	self.ivelocity1 = self.ivelocity2;
-
-	self.iorigin2 = self.origin;
-	self.iforward2 = v_forward;
-	self.iright2 = v_right;
-	self.ivelocity2 = self.velocity;
-
-	dt = time - self.itime1;
-
-	if(vlen(self.iorigin2 - self.iorigin1) > 1000)
-	{
-		self.iorigin1 = self.iorigin2;
-		self.iforward1 = self.iforward2;
-		self.iright1 = self.iright2;
-		self.ivelocity1 = self.ivelocity2;
-	}
-	else if(vlen(self.ivelocity2 - self.ivelocity1) > 1000)
-	{
-		self.iforward1 = self.iforward2;
-		self.iright1 = self.iright2;
-		self.ivelocity1 = self.ivelocity2;
-	}
-
-	if(dt < 0.2)
-	{
-		self.itime1 = time;
-		self.itime2 = time + getstatf(STAT_SYS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
-	}
-	else
-	{
-		// don't lerp
-		self.itime1 = self.itime2 = time;
-	}
-}
-void InterpolateOrigin_Do()
-{
-	vector forward, right;
-	if(self.itime1 && self.itime2 && self.itime1 != self.itime2)
-	{
-		float f;
-		f = bound(0, (time - self.itime1) / (self.itime2 - self.itime1), 1);
-		self.origin = (1 - f) * self.iorigin1 + f * self.iorigin2;
-		forward = (1 - f) * self.iforward1 + f * self.iforward2;
-		right = (1 - f) * self.iright1 + f * self.iright2;
-		self.angles = vectoangles(forward, right);
-		self.angles_x = -self.angles_x;
-		self.velocity = (1 - f) * self.ivelocity1 + f * self.ivelocity2;
-	}
-}
-void InterpolateOrigin_Undo()
-{
-	self.origin = self.iorigin2;
-	self.angles = vectoangles(self.iforward2, self.iright2);
-	self.angles_x = -self.angles_x;
-	self.velocity = self.ivelocity2;
-}
-
 // a laser goes from origin in direction angles
 // it has color 'colormod'
 // and stops when something is in the way
@@ -121,10 +49,17 @@
 void Ent_Laser()
 {
 	float f;
+	InterpolateOrigin_Undo();
+
 	// 30 bytes, or 13 bytes for just moving
 	f = ReadByte();
 	self.count = (f & 0xC0);
-	InterpolateOrigin_Undo();
+
+	if(self.count & 0x80)
+		self.iflags = IFLAG_VELOCITY;
+	else
+		self.iflags = IFLAG_ANGLES;
+
 	if(f & 1)
 	{
 		self.origin_x = ReadCoord();

Modified: trunk/data/qcsrc/client/progs.src
===================================================================
--- trunk/data/qcsrc/client/progs.src	2008-09-30 18:31:39 UTC (rev 4563)
+++ trunk/data/qcsrc/client/progs.src	2008-10-01 06:06:25 UTC (rev 4564)
@@ -7,7 +7,9 @@
 
 csqc_builtins.qc
 
+../common/mapinfo.qh
 ../common/util.qh
+interpolate.qh
 
 main.qh
 
@@ -27,6 +29,8 @@
 
 Main.qc
 View.qc
+interpolate.qc
 
 ../common/util.qc
 ../common/gamecommand.qc
+../common/mapinfo.qc

Modified: trunk/data/qcsrc/common/mapinfo.qc
===================================================================
--- trunk/data/qcsrc/common/mapinfo.qc	2008-09-30 18:31:39 UTC (rev 4563)
+++ trunk/data/qcsrc/common/mapinfo.qc	2008-10-01 06:06:25 UTC (rev 4564)
@@ -1,32 +1,3 @@
-// internal toy
-void cvar_settemp(string pKey, string pValue)
-{
-	//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 ", pKey, " ", cvar_string("settemp_var"), " ", cvar_string("settemp_list")));
-#ifdef MENUQC
-	registercvar(cvar_string("settemp_var"), "", 0);
-#else
-	registercvar(cvar_string("settemp_var"), "");
-#endif
-	cvar_set(cvar_string("settemp_var"), cvar_string(pKey));
-	cvar_set("settemp_var", strcat(cvar_string("settemp_var"), "x"));
-	cvar_set(pKey, pValue);
-}
-
-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");
-}
-
 #ifdef HSOI
 // HUGE SET - stored in a string
 string HugeSetOfIntegers_empty()
@@ -476,6 +447,8 @@
 	MapInfo_Map_supportedFeatures = 0;
 	MapInfo_Map_clientstuff = "";
 	MapInfo_Map_fog = "";
+	MapInfo_Map_mins = '0 0 0';
+	MapInfo_Map_maxs = '0 0 0';
 }
 
 void _MapInfo_Map_ApplyGametype(string s, float pWantedType, float pThisType)
@@ -591,6 +564,11 @@
 			fputs(fh, "settemp_for_type all sv_q3acompat_machineshotgunswap 1\n");
 		}
 
+		fputs(fh, "// optional: fog density red green blue alpha mindist maxdist\n");
+		fputs(fh, "// optional: settemp_for_type (all|gametypename) cvarname value\n");
+		fputs(fh, "// optional: clientsettemp_for_type (all|gametypename) cvarname value\n");
+		fputs(fh, "// optional: size mins_x mins_y mins_z maxs_x maxs_y maxs_z (for team map)\n");
+
 		fclose(fh);
 		r = 2;
 		// return r;
@@ -638,6 +616,37 @@
 			else
 				dprint("Map ", pFilename, " supports unknown game type ", t, ", ignored\n");
 		}
+		else if(t == "size")
+		{
+			float a, b, c, d, e, f;
+			t = car(s); s = cdr(s); a = stof(t);
+			t = car(s); s = cdr(s); b = stof(t);
+			t = car(s); s = cdr(s); c = stof(t);
+			t = car(s); s = cdr(s); d = stof(t);
+			t = car(s); s = cdr(s); e = stof(t);
+			if(s == "")
+				print("Map ", pFilename, " contains an incorrect size line, syntax: size mins_x mins_y mins_z maxs_x maxs_y maxs_z\n");
+			else
+			{
+				t = car(s); s = cdr(s); f = stof(t);
+				if(s == "")
+					print("Map ", pFilename, " contains an incorrect size line, syntax: size mins_x mins_y mins_z maxs_x maxs_y maxs_z\n");
+				else
+				{
+					if(a >= d || b >= e || c >= f)
+						print("Map ", pFilename, " contains an incorrect size line, mins have to be < maxs\n");
+					else
+					{
+						MapInfo_Map_mins_x = a;
+						MapInfo_Map_mins_y = b;
+						MapInfo_Map_mins_z = c;
+						MapInfo_Map_maxs_x = d;
+						MapInfo_Map_maxs_y = e;
+						MapInfo_Map_maxs_z = f;
+					}
+				}
+			}
+		}
 		else if(t == "settemp_for_type")
 		{
 			t = car(s); s = cdr(s);

Modified: trunk/data/qcsrc/common/mapinfo.qh
===================================================================
--- trunk/data/qcsrc/common/mapinfo.qh	2008-09-30 18:31:39 UTC (rev 4563)
+++ trunk/data/qcsrc/common/mapinfo.qh	2008-10-01 06:06:25 UTC (rev 4564)
@@ -24,6 +24,8 @@
 string MapInfo_Map_fog;
 float MapInfo_Map_supportedGametypes;
 float MapInfo_Map_supportedFeatures;
+vector MapInfo_Map_mins; // these are '0 0 0' if not supported!
+vector MapInfo_Map_maxs; // these are '0 0 0' if not specified!
 
 // load MapInfo_count; generate mapinfo for maps that miss them, and clear the
 // cache; you need to call MapInfo_FilterGametype afterwards!

Modified: trunk/data/qcsrc/common/util.qc
===================================================================
--- trunk/data/qcsrc/common/util.qc	2008-09-30 18:31:39 UTC (rev 4563)
+++ trunk/data/qcsrc/common/util.qc	2008-10-01 06:06:25 UTC (rev 4564)
@@ -711,3 +711,80 @@
 		return 0;
 	return 1;
 }
+
+#ifndef MENUQC
+void get_mi_min_max()
+{
+	if(mi_shortname)
+		strunzone(mi_shortname);
+	mi_shortname = mapname;
+	if(!strcasecmp(substring(mi_shortname, 0, 5), "maps/"))
+		mi_shortname = substring(mi_shortname, 5, strlen(mi_shortname) - 5);
+	if(!strcasecmp(substring(mi_shortname, strlen(mi_shortname) - 4, 4), ".bsp"))
+		mi_shortname = substring(mi_shortname, 0, strlen(mi_shortname) - 4);
+	mi_shortname = strzone(mi_shortname);
+
+	mi_min = world.mins;
+	mi_max = world.maxs;
+	MapInfo_Get_ByName(mi_shortname, 0, 0);
+	if(MapInfo_Map_mins_x < MapInfo_Map_maxs_x)
+	{
+		mi_min = MapInfo_Map_mins;
+		mi_max = MapInfo_Map_maxs;
+	}
+
+	mi_picmin = mi_min;
+	mi_picmax = mi_max;
+
+	// extend mi_picmax to get a square aspect ratio
+	mi_picmax_x = max(mi_picmax_x, mi_picmin_x + (mi_max_y - mi_min_y));
+	mi_picmax_y = max(mi_picmax_y, mi_picmin_y + (mi_max_x - mi_min_x));
+
+	// calculate the texcoords
+	mi_pictexcoord0 = mi_pictexcoord1 = mi_pictexcoord2 = mi_pictexcoord3 = '0 0 0';
+	// first the two corners of the origin
+	mi_pictexcoord0_x = (mi_min_x - mi_picmin_x) / (mi_picmax_x - mi_picmin_x);
+	mi_pictexcoord0_y = (mi_min_y - mi_picmin_y) / (mi_picmax_y - mi_picmin_y);
+	mi_pictexcoord2_x = (mi_max_x - mi_picmin_x) / (mi_picmax_x - mi_picmin_x);
+	mi_pictexcoord2_y = (mi_max_y - mi_picmin_y) / (mi_picmax_y - mi_picmin_y);
+	// then the other corners
+	mi_pictexcoord1_x = mi_pictexcoord0_x;
+	mi_pictexcoord1_y = mi_pictexcoord2_y;
+	mi_pictexcoord3_x = mi_pictexcoord2_x;
+	mi_pictexcoord3_y = mi_pictexcoord0_y;
+}
+#endif
+
+#ifdef CSQC
+void cvar_settemp(string pKey, string pValue)
+{
+	error("cvar_settemp called from CSQC - use cvar_clientsettemp instead!");
+}
+void cvar_settemp_restore()
+{
+	error("cvar_settemp_restore called from CSQC - use cvar_clientsettemp instead!");
+}
+#else
+void cvar_settemp(string pKey, string pValue)
+{
+	cvar_set("settemp_list", strcat("1 ", pKey, " ", cvar_string("settemp_var"), " ", cvar_string("settemp_list")));
+#ifdef MENUQC
+	registercvar(cvar_string("settemp_var"), "", 0);
+#else
+	registercvar(cvar_string("settemp_var"), "");
+#endif
+	cvar_set(cvar_string("settemp_var"), cvar_string(pKey));
+	cvar_set("settemp_var", strcat(cvar_string("settemp_var"), "x"));
+	cvar_set(pKey, pValue);
+}
+
+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");
+}
+#endif

Modified: trunk/data/qcsrc/common/util.qh
===================================================================
--- trunk/data/qcsrc/common/util.qh	2008-09-30 18:31:39 UTC (rev 4563)
+++ trunk/data/qcsrc/common/util.qh	2008-10-01 06:06:25 UTC (rev 4564)
@@ -78,3 +78,19 @@
 string swapInPriorityList(string order, float i, float j);
 
 float cvar_value_issafe(string s);
+
+void cvar_settemp(string pKey, string pValue);
+void cvar_settemp_restore();
+
+#ifndef MENUQC
+string mi_shortname;
+vector mi_min;
+vector mi_max;
+vector mi_picmin; // adjusted mins that map to the picture (square)
+vector mi_picmax; // adjusted maxs that map to the picture (square)
+vector mi_pictexcoord0; // texcoords of the image corners (after transforming, these are 2D coords too)
+vector mi_pictexcoord1; // texcoords of the image corners (after transforming, these are 2D coords too)
+vector mi_pictexcoord2; // texcoords of the image corners (after transforming, these are 2D coords too)
+vector mi_pictexcoord3; // texcoords of the image corners (after transforming, these are 2D coords too)
+void get_mi_min_max();
+#endif

Modified: trunk/data/qcsrc/menu/progs.src
===================================================================
--- trunk/data/qcsrc/menu/progs.src	2008-09-30 18:31:39 UTC (rev 4563)
+++ trunk/data/qcsrc/menu/progs.src	2008-10-01 06:06:25 UTC (rev 4564)
@@ -7,8 +7,8 @@
 oo/base.h
 
 ../common/constants.qh
+../common/mapinfo.qh
 ../common/util.qh
-../common/mapinfo.qh
 ../common/campaign_common.qh
 
 gamecommand.qh

Modified: trunk/data/qcsrc/server/gamecommand.qc
===================================================================
--- trunk/data/qcsrc/server/gamecommand.qc	2008-09-30 18:31:39 UTC (rev 4563)
+++ trunk/data/qcsrc/server/gamecommand.qc	2008-10-01 06:06:25 UTC (rev 4564)
@@ -37,15 +37,15 @@
 	return floor(FullTraceFraction(a, mi, ma, b) / (world.maxs_z - world.mins_z) * 255);
 }
 #else
-float RoughMapAtPoint(float x, float y, float w, float h)
+float RoughMapAtPoint(float x, float y, float w, float h, vector mi_min, vector mi_max)
 {
 	vector o, mi, ma;
 	float i, r;
 	vector dz;
 	mi = '0 0 0';
-	dz = ((world.maxs_z - world.mins_z) / 64) * '0 0 1';
+	dz = ((mi_max_z - mi_min_z) / 64) * '0 0 1';
 	ma = '1 0 0' * w + '0 1 0' * h + dz;
-	o = '1 0 0' * x + '0 1 0' * y + '0 0 1' * world.mins_z;
+	o = '1 0 0' * x + '0 1 0' * y + '0 0 1' * mi_min_z;
 	
 	r = 0;
 	for(i = 0; i < 51; ++i)
@@ -62,7 +62,7 @@
 
 void RoughMap()
 {
-	float x0, y0, w, h;
+	float w, h;
 	float m, n;
 	float x, y;
 	float l;
@@ -71,22 +71,17 @@
 	string si;
 	string fn;
 
+	get_mi_min_max();
+
 	m = 256;
 	n = 256;
 
-	x0 = world.mins_x;
-	y0 = world.mins_y;
-	w = (world.maxs_x - x0) / m;
-	h = (world.maxs_y - y0) / n;
-	// TODO fix aspect
-	w = h = max(w, h);
+	w = (mi_picmax_x - mi_picmin_x) / m;
+	h = (mi_picmax_y - mi_picmin_y) / n;
 
-	/*
-	m = min(m, ceil((world.maxs_x - x0) / w));
-	n = min(n, ceil((world.maxs_y - y0) / h));
-	*/
+	print("Picture mins/maxs: ", ftos(w), " and ", ftos(h), " should match\n");
 
-	fn = strcat("maps/", mapname, ".xpm");
+	fn = strcat("maps/", mi_shortname, "_mini.xpm");
 	f = fopen(fn, FILE_WRITE);
 	if(f < 0)
 	{
@@ -108,7 +103,7 @@
 		fputs(f, "\"");
 		for(x = 0; x < m; ++x)
 		{
-			l = RoughMapAtPoint(x0 + x * w, y0 + y * h, w, h);
+			l = RoughMapAtPoint(mi_min_x + x * w, mi_min_y + y * h, w, h, mi_picmin, mi_picmax);
 			fputs(f, substring(doublehex, 2 * l, 2));
 		}
 		if(y == 0)
@@ -120,7 +115,8 @@
 		}
 	}
 	fputs(f, "};\n");
-	print("Finished. Please edit data/", fn, " with an image editing application and place it with the name XXX in the TGA format in the same folder as the BSP file.\n");
+	fclose(f);
+	print("Finished. Please edit data/", fn, " with an image editing application and place it in the TGA format in the same folder as the BSP file.\n");
 }
 
 void EffectIndexDump()

Modified: trunk/data/qcsrc/server/progs.src
===================================================================
--- trunk/data/qcsrc/server/progs.src	2008-09-30 18:31:39 UTC (rev 4563)
+++ trunk/data/qcsrc/server/progs.src	2008-10-01 06:06:25 UTC (rev 4564)
@@ -13,11 +13,10 @@
 
 campaign.qh
 ../common/campaign_common.qh
+../common/mapinfo.qh
 ../common/util.qh
 ../common/util.qc
 
-../common/mapinfo.qh
-
 portals.qh
 
 scores.qh




More information about the nexuiz-commits mailing list