From ae290926c485b24f665a75864f03fc6f512a5738 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 3 Dec 2000 23:52:54 +0000 Subject: [PATCH] WildCode's location marking code (with a little touchup). --- include/locs.h | 6 +++++ include/teamplay.h | 6 +++++ source/cl_main.c | 1 + source/teamplay.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+) diff --git a/include/locs.h b/include/locs.h index 308bcc1..8563f66 100644 --- a/include/locs.h +++ b/include/locs.h @@ -26,6 +26,9 @@ $Id$ */ +#ifndef __locs_h +#define __locs_h + #include "qtypes.h" typedef struct @@ -37,3 +40,6 @@ typedef struct location_t *locs_find(vec3_t target); void locs_load(char *mapname); void locs_reset(); +void locs_add(vec3_t location, char *name); + +#endif // __locs_h diff --git a/include/teamplay.h b/include/teamplay.h index 86722f0..ea0e7f7 100644 --- a/include/teamplay.h +++ b/include/teamplay.h @@ -26,6 +26,9 @@ $Id$ */ +#ifndef __teamplay_h +#define __teamplay_h + #include "cvar.h" extern cvar_t *cl_deadbodyfilter; @@ -38,3 +41,6 @@ void Team_BestWeaponImpulse (void); void Team_Dead (void); void Team_NewMap (void); char *Team_ParseSay (char *); +void Locs_Init (void); + +#endif // __teamplay_h diff --git a/source/cl_main.c b/source/cl_main.c index 38baf29..22b61a1 100644 --- a/source/cl_main.c +++ b/source/cl_main.c @@ -1592,6 +1592,7 @@ void Host_Init (void) Cbuf_Init (); Cmd_Init (); + Locs_Init (); // execute +set as early as possible Cmd_StuffCmds_f (); diff --git a/source/teamplay.c b/source/teamplay.c index 29b8a10..0247c15 100644 --- a/source/teamplay.c +++ b/source/teamplay.c @@ -27,6 +27,7 @@ */ #include +#include #include "bothdefs.h" #include "cmd.h" @@ -34,6 +35,8 @@ #include "teamplay.h" #include "locs.h" #include "sys.h" +#include "console.h" +#include "quakefs.h" extern cvar_t *skin; cvar_t *cl_deadbodyfilter; @@ -306,3 +309,57 @@ void Team_Init_Cvars (void) cl_parsesay = Cvar_Get("cl_parsesay", "0", CVAR_NONE, "None"); cl_nofake = Cvar_Get("cl_nofake", "0", CVAR_NONE, "Unhide fake messages"); } + +/* + * locs_markloc + * + * Record the current co-ords plus description into a loc file for current map + * */ + +// FIXME: No gzip'd loc file support + +void locs_markloc() +{ + vec3_t loc; + char *mapname, *t1; + QFile *locfd; + char locfile[MAX_OSPATH]; + + if (Cmd_Argc() != 2) { + Con_Printf("markloc :marks the current location with the description and records the information into a loc file.\n"); + return; + } + VectorCopy(cl.simorg,loc); + locs_add(loc,Cmd_Argv(1)); + loc[0] *= 8; + loc[1] *= 8; + loc[2] *= 8; + mapname = strdup(cl.worldmodel->name); + if (!mapname) + Sys_Error("Can't duplicate mapname!"); + t1 = strrchr(mapname, '.'); + if (!t1) + Sys_Error("Can't find / or .!"); + t1++; // skip over / + t1[0] = 'l'; + t1[1] = 'o'; + t1[2] = 'c'; + snprintf(locfile, sizeof(locfile), "%s/%s",com_gamedir,mapname); + locfd = Qopen(locfile,"a+"); + if (locfd == 0) { + Qopen(locfile,"w+"); + if (locfd == 0) { + Con_Printf("ERROR: Unable to open %s : %s\n",mapname,strerror(errno)); + free(mapname); + return; + } + } + Qprintf(locfd,"%.0f %.0f %.0f %s\n",loc[0],loc[1],loc[2],Cmd_Argv(1)); + Qclose(locfd); + free(mapname); +} + void Locs_Init() +{ + Cmd_AddCommand("markloc",locs_markloc); +} +