For loadboard() and friends, pass a vec3_t position instead of separate x/y/z.

git-svn-id: https://svn.eduke32.com/eduke32@3042 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-10-01 17:52:30 +00:00
parent f10bfb6774
commit 9128e8af04
8 changed files with 52 additions and 62 deletions

View file

@ -580,15 +580,13 @@ int32_t preinitengine(void); // a partial setup of the engine used for launch
int32_t initengine(void);
void uninitengine(void);
void initspritelists(void);
int32_t loadboard(char *filename, char flags, int32_t *daposx, int32_t *daposy, int32_t *daposz,
int16_t *daang, int16_t *dacursectnum);
int32_t loadboard(char *filename, char flags, vec3_t *dapos, int16_t *daang, int16_t *dacursectnum);
int32_t loadmaphack(const char *filename);
void delete_maphack_lights();
#ifdef HAVE_CLIPSHAPE_FEATURE
int32_t clipmapinfo_load(void);
#endif
int32_t saveboard(const char *filename, int32_t *daposx, int32_t *daposy, int32_t *daposz,
int16_t *daang, int16_t *dacursectnum);
int32_t saveboard(const char *filename, const vec3_t *dapos, int16_t daang, int16_t dacursectnum);
void set_picsizanm(int32_t picnum, int16_t dasizx, int16_t dasizy, int32_t daanm);
int32_t loadpics(const char *filename, int32_t askedsize);
void loadtile(int16_t tilenume);
@ -870,8 +868,7 @@ int32_t loaddefinitionsfile(const char *fn);
// if loadboard() fails with -2 return, try loadoldboard(). if it fails with
// -2, board is dodgy
extern int32_t mapversion;
int32_t loadoldboard(char *filename, char fromwhere, int32_t *daposx, int32_t *daposy, int32_t *daposz,
int16_t *daang, int16_t *dacursectnum);
int32_t loadoldboard(char *filename, char fromwhere, vec3_t *dapos, int16_t *daang, int16_t *dacursectnum);
// Hash functions

View file

@ -70,7 +70,7 @@ extern uint8_t buildkeys[NUMBUILDKEYS];
extern double vid_gamma_3d, vid_contrast_3d, vid_brightness_3d;
extern double msens;
extern int32_t startposx, startposy, startposz;
extern vec3_t startpos;
extern int16_t startang, startsectnum;
extern int32_t lastpm16time, synctics;

View file

@ -3155,9 +3155,9 @@ void overheadeditor(void)
int32_t cx, cy;
// Draw brown arrow (start)
screencoords(&x2, &y2, startposx-pos.x,startposy-pos.y, zoom);
screencoords(&x2, &y2, startpos.x-pos.x,startpos.y-pos.y, zoom);
if (m32_sideview)
y2 += getscreenvdisp(startposz-pos.z, zoom);
y2 += getscreenvdisp(startpos.z-pos.z, zoom);
cx = halfxdim16+x2;
cy = midydim16+y2;
@ -3704,9 +3704,7 @@ rotate_hlsect_out:
if (keystatus[0x46]) //Scroll lock (set starting position)
{
startposx = pos.x;
startposy = pos.y;
startposz = pos.z;
startpos = pos;
startang = ang;
startsectnum = cursectnum;
keystatus[0x46] = 0;
@ -7751,7 +7749,7 @@ const char *SaveBoard(const char *fn, uint32_t flags)
}
saveboard_fixedsprites = ExtPreSaveMap();
ret = saveboard(f,&startposx,&startposy,&startposz,&startang,&startsectnum);
ret = saveboard(f, &startpos, startang, startsectnum);
if ((flags&1)==0)
{
ExtSaveMap(f);
@ -7784,9 +7782,9 @@ int32_t LoadBoard(const char *filename, uint32_t flags)
editorzrange[1] = INT32_MAX;
ExtPreLoadMap();
i = loadboard(boardfilename,(flags&4)|loadingflags, &pos.x,&pos.y,&pos.z,&ang,&cursectnum);
i = loadboard(boardfilename, (flags&4)|loadingflags, &pos, &ang, &cursectnum);
if (i == -2)
i = loadoldboard(boardfilename,loadingflags, &pos.x,&pos.y,&pos.z,&ang,&cursectnum);
i = loadoldboard(boardfilename,loadingflags, &pos, &ang, &cursectnum);
if (i < 0)
{
// printmessage16("Invalid map format.");
@ -7814,9 +7812,7 @@ int32_t LoadBoard(const char *filename, uint32_t flags)
i==0?"successfully": (i<4 ? "(moderate corruption)" : "(HEAVY corruption)"));
}
startposx = pos.x; //this is same
startposy = pos.y;
startposz = pos.z;
startpos = pos; //this is same
startang = ang;
startsectnum = cursectnum;
@ -10269,7 +10265,7 @@ void test_map(int32_t mode)
if (!mode)
updatesector(pos.x, pos.y, &cursectnum);
else
updatesector(startposx, startposy, &startsectnum);
updatesector(startpos.x, startpos.y, &startsectnum);
#ifdef _WIN32
if (fullscreen)
@ -10335,9 +10331,9 @@ void test_map(int32_t mode)
ExtPreSaveMap();
if (mode)
saveboard(PLAYTEST_MAPNAME,&startposx,&startposy,&startposz,&startang,&startsectnum);
saveboard(PLAYTEST_MAPNAME, &startpos, startang, startsectnum);
else
saveboard(PLAYTEST_MAPNAME,&pos.x,&pos.y,&pos.z,&ang,&cursectnum);
saveboard(PLAYTEST_MAPNAME, &pos, ang, cursectnum);
message("Board saved to " PLAYTEST_MAPNAME ". Starting the game...");
OSD_Printf("...as `%s'\n", fullparam);

View file

@ -1282,8 +1282,7 @@ static void clipmapinfo_init()
// this should be called before any real map is loaded.
int32_t clipmapinfo_load(void)
{
int32_t i,k,w, px,py,pz;
int16_t ang,cs;
int32_t i,k,w;
int32_t lwcp = 0;
int32_t fi;
@ -1313,10 +1312,13 @@ int32_t clipmapinfo_load(void)
quickloadboard = 1;
for (fi = 0; fi < g_clipMapFilesNum; ++fi)
{
int16_t ang,cs;
vec3_t tmppos;
fisec[fi] = ournumsectors;
fispr[fi] = ournumsprites;
i = loadboard(g_clipMapFiles[fi], 0, &px,&py,&pz, &ang,&cs);
i = loadboard(g_clipMapFiles[fi], 0, &tmppos, &ang, &cs);
if (i<0)
continue;
// Numsprites will now be set!
@ -2262,7 +2264,7 @@ static int32_t globalx, globaly, globalz;
int16_t sectorborder[256], sectorbordercnt;
int32_t ydim16, qsetmode = 0;
int32_t startposx, startposy, startposz;
vec3_t startpos;
int16_t startang, startsectnum;
int16_t pointhighlight=-1, linehighlight=-1, highlightcnt=0;
#ifndef OBSOLETE_RENDMODES
@ -9301,8 +9303,7 @@ void drawmapview(int32_t dax, int32_t day, int32_t zoome, int16_t ang)
// 4: don't call polymer_loadboard
// returns: -1: file not found
// -2: invalid version
int32_t loadboard(char *filename, char flags, int32_t *daposx, int32_t *daposy, int32_t *daposz,
int16_t *daang, int16_t *dacursectnum)
int32_t loadboard(char *filename, char flags, vec3_t *dapos, int16_t *daang, int16_t *dacursectnum)
{
int16_t fil, i, numsprites;
#ifdef POLYMER
@ -9344,9 +9345,9 @@ int32_t loadboard(char *filename, char flags, int32_t *daposx, int32_t *daposy,
Bmemset(show2dsprite, 0, sizeof(show2dsprite));
Bmemset(show2dwall, 0, sizeof(show2dwall));
kread(fil,daposx,4); *daposx = B_LITTLE32(*daposx);
kread(fil,daposy,4); *daposy = B_LITTLE32(*daposy);
kread(fil,daposz,4); *daposz = B_LITTLE32(*daposz);
kread(fil,&dapos->x,4); dapos->x = B_LITTLE32(dapos->x);
kread(fil,&dapos->y,4); dapos->y = B_LITTLE32(dapos->y);
kread(fil,&dapos->z,4); dapos->z = B_LITTLE32(dapos->z);
kread(fil,daang,2); *daang = B_LITTLE16(*daang);
kread(fil,dacursectnum,2); *dacursectnum = B_LITTLE16(*dacursectnum);
@ -9436,7 +9437,7 @@ int32_t loadboard(char *filename, char flags, int32_t *daposx, int32_t *daposy,
#ifdef YAX_ENABLE
yax_update(mapversion<9);
if (editstatus)
yax_updategrays(*daposz);
yax_updategrays(dapos->z);
#endif
for (i=0; i<numsprites; i++)
{
@ -9447,7 +9448,7 @@ int32_t loadboard(char *filename, char flags, int32_t *daposx, int32_t *daposy,
}
//Must be after loading sectors, etc!
updatesector(*daposx,*daposy,dacursectnum);
updatesector(dapos->x, dapos->y, dacursectnum);
kclose(fil);
@ -9473,9 +9474,7 @@ int32_t loadboard(char *filename, char flags, int32_t *daposx, int32_t *daposy,
}
guniqhudid = 0;
startposx = *daposx;
startposy = *daposy;
startposz = *daposz;
startpos = *dapos;
startang = *daang;
startsectnum = *dacursectnum;
@ -9742,8 +9741,7 @@ static void convertv6sprv7(struct spritetypev6 *from, spritetype *to)
// Powerslave uses v6
// Witchaven 1 and TekWar and LameDuke use v5
int32_t loadoldboard(char *filename, char fromwhere, int32_t *daposx, int32_t *daposy, int32_t *daposz,
int16_t *daang, int16_t *dacursectnum)
int32_t loadoldboard(char *filename, char fromwhere, vec3_t *dapos, int16_t *daang, int16_t *dacursectnum)
{
int16_t fil, i, numsprites;
struct sectortypev5 v5sect;
@ -9767,9 +9765,9 @@ int32_t loadoldboard(char *filename, char fromwhere, int32_t *daposx, int32_t *d
Bmemset(show2dsprite, 0, sizeof(show2dsprite));
Bmemset(show2dwall, 0, sizeof(show2dwall));
kread(fil,daposx,4); *daposx = B_LITTLE32(*daposx);
kread(fil,daposy,4); *daposy = B_LITTLE32(*daposy);
kread(fil,daposz,4); *daposz = B_LITTLE32(*daposz);
kread(fil,&dapos->x,4); dapos->x = B_LITTLE32(dapos->x);
kread(fil,&dapos->y,4); dapos->y = B_LITTLE32(dapos->y);
kread(fil,&dapos->z,4); dapos->z = B_LITTLE32(dapos->z);
kread(fil,daang,2); *daang = B_LITTLE16(*daang);
kread(fil,dacursectnum,2); *dacursectnum = B_LITTLE16(*dacursectnum);
@ -9921,7 +9919,7 @@ int32_t loadoldboard(char *filename, char fromwhere, int32_t *daposx, int32_t *d
}
//Must be after loading sectors, etc!
updatesector(*daposx,*daposy,dacursectnum);
updatesector(dapos->x, dapos->y, dacursectnum);
kclose(fil);
@ -10261,8 +10259,7 @@ int32_t loadmaphack(const char *filename)
//
// saveboard
//
int32_t saveboard(const char *filename, int32_t *daposx, int32_t *daposy, int32_t *daposz,
int16_t *daang, int16_t *dacursectnum)
int32_t saveboard(const char *filename, const vec3_t *dapos, int16_t daang, int16_t dacursectnum)
{
int16_t fil, i, j, numsprites, ts;
int32_t tl;
@ -10318,11 +10315,11 @@ int32_t saveboard(const char *filename, int32_t *daposx, int32_t *daposy, int32_
mapversion = 7;
tl = B_LITTLE32(mapversion); Bwrite(fil,&tl,4);
tl = B_LITTLE32(*daposx); Bwrite(fil,&tl,4);
tl = B_LITTLE32(*daposy); Bwrite(fil,&tl,4);
tl = B_LITTLE32(*daposz); Bwrite(fil,&tl,4);
ts = B_LITTLE16(*daang); Bwrite(fil,&ts,2);
ts = B_LITTLE16(*dacursectnum); Bwrite(fil,&ts,2);
tl = B_LITTLE32(dapos->x); Bwrite(fil,&tl,4);
tl = B_LITTLE32(dapos->y); Bwrite(fil,&tl,4);
tl = B_LITTLE32(dapos->z); Bwrite(fil,&tl,4);
ts = B_LITTLE16(daang); Bwrite(fil,&ts,2);
ts = B_LITTLE16(dacursectnum); Bwrite(fil,&ts,2);
ts = B_LITTLE16(numsectors); Bwrite(fil,&ts,2);

View file

@ -814,7 +814,7 @@ void ExtLoadMap(const char *mapname)
void ExtSaveMap(const char *mapname)
{
UNREFERENCED_PARAMETER(mapname);
saveboard("backup.map",&pos.x,&pos.y,&pos.z,&ang,&cursectnum);
saveboard("backup.map", &pos, ang, cursectnum);
}
@ -8384,9 +8384,9 @@ int32_t ExtPreSaveMap(void)
int32_t numfixedsprites;
numfixedsprites = fixspritesectors(); //Do this before saving!
updatesectorz(startposx,startposy,startposz,&startsectnum);
updatesectorz(startpos.x,startpos.y,startpos.z,&startsectnum);
if (startsectnum < 0)
updatesector(startposx,startposy,&startsectnum);
updatesector(startpos.x,startpos.y,&startsectnum);
if (fixmaponsave_walls)
{

View file

@ -3939,8 +3939,8 @@ static void G_DumpDebugInfo(void)
}
Gv_DumpValues();
// fclose(fp);
saveboard("debug.map",&g_player[myconnectindex].ps->pos.x,&g_player[myconnectindex].ps->pos.y,
&g_player[myconnectindex].ps->pos.z,&g_player[myconnectindex].ps->ang,&g_player[myconnectindex].ps->cursectnum);
saveboard("debug.map", &g_player[myconnectindex].ps->pos, g_player[myconnectindex].ps->ang,
g_player[myconnectindex].ps->cursectnum);
}
int32_t A_InsertSprite(int32_t whatsect,int32_t s_x,int32_t s_y,int32_t s_z,int32_t s_pn,int32_t s_s,

View file

@ -604,9 +604,9 @@ static void Gv_AddSystemVars(void)
Gv_NewVar("tempyrepeat",(intptr_t)&tempyrepeat, GAMEVAR_INTPTR|GAMEVAR_SYSTEM|GAMEVAR_READONLY);
// starting position
Gv_NewVar("startposx",(intptr_t)&startposx, GAMEVAR_READONLY | GAMEVAR_INTPTR | GAMEVAR_SYSTEM);
Gv_NewVar("startposy",(intptr_t)&startposy, GAMEVAR_READONLY | GAMEVAR_INTPTR | GAMEVAR_SYSTEM);
Gv_NewVar("startposz",(intptr_t)&startposz, GAMEVAR_READONLY | GAMEVAR_INTPTR | GAMEVAR_SYSTEM);
Gv_NewVar("startposx",(intptr_t)&startpos.x, GAMEVAR_READONLY | GAMEVAR_INTPTR | GAMEVAR_SYSTEM);
Gv_NewVar("startposy",(intptr_t)&startpos.y, GAMEVAR_READONLY | GAMEVAR_INTPTR | GAMEVAR_SYSTEM);
Gv_NewVar("startposz",(intptr_t)&startpos.z, GAMEVAR_READONLY | GAMEVAR_INTPTR | GAMEVAR_SYSTEM);
Gv_NewVar("startang",(intptr_t)&startang, GAMEVAR_READONLY | GAMEVAR_SHORTPTR | GAMEVAR_SYSTEM);
Gv_NewVar("startsectnum",(intptr_t)&startsectnum, GAMEVAR_READONLY | GAMEVAR_SHORTPTR | GAMEVAR_SYSTEM);

View file

@ -1935,8 +1935,8 @@ int32_t G_EnterLevel(int32_t g)
{
if (boardfilename[0] != 0 && ud.m_level_number == 7 && ud.m_volume_number == 0)
{
if (loadboard(boardfilename,0,&g_player[0].ps->pos.x, &g_player[0].ps->pos.y,
&g_player[0].ps->pos.z, &g_player[0].ps->ang,&g_player[0].ps->cursectnum) < 0)
if (loadboard(boardfilename, 0, &g_player[0].ps->pos, &g_player[0].ps->ang,
&g_player[0].ps->cursectnum) < 0)
{
OSD_Printf(OSD_ERROR "Map \"%s\" not found or invalid map version!\n",boardfilename);
@ -1948,8 +1948,8 @@ int32_t G_EnterLevel(int32_t g)
G_SetupFilenameBasedMusic(levname, boardfilename, ud.m_level_number);
}
else if (loadboard(MapInfo[mii].filename,0,&g_player[0].ps->pos.x,
&g_player[0].ps->pos.y, &g_player[0].ps->pos.z, &g_player[0].ps->ang,&g_player[0].ps->cursectnum) < 0)
else if (loadboard(MapInfo[mii].filename,0, &g_player[0].ps->pos, &g_player[0].ps->ang,
&g_player[0].ps->cursectnum) < 0)
{
OSD_Printf(OSD_ERROR "Map \"%s\" not found or invalid map version!\n",
MapInfo[mii].filename);
@ -1969,8 +1969,8 @@ int32_t G_EnterLevel(int32_t g)
levname[i] = 255; // leads to flags=1 for kopen4load
levname[i+1] = 0;
if (loadboard(levname,1,&g_player[0].ps->pos.x, &g_player[0].ps->pos.y,
&g_player[0].ps->pos.z, &g_player[0].ps->ang,&g_player[0].ps->cursectnum) < 0)
if (loadboard(levname,1, &g_player[0].ps->pos, &g_player[0].ps->ang,
&g_player[0].ps->cursectnum) < 0)
{
OSD_Printf(OSD_ERROR "Map \"%s\" not found or invalid map version!\n",
MapInfo[mii].filename);