WildCode's location marking code (with a little touchup).

This commit is contained in:
Bill Currie 2000-12-03 23:52:54 +00:00
parent 5910c51bbe
commit ae290926c4
4 changed files with 70 additions and 0 deletions

View file

@ -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

View file

@ -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

View file

@ -1592,6 +1592,7 @@ void Host_Init (void)
Cbuf_Init ();
Cmd_Init ();
Locs_Init ();
// execute +set as early as possible
Cmd_StuffCmds_f ();

View file

@ -27,6 +27,7 @@
*/
#include <string.h>
#include <errno.h>
#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 <description> :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);
}