Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • STJr/SRB2
  • Sryder/SRB2
  • wolfy852/SRB2
  • Alpha2244/SRB2
  • Inuyasha/SRB2
  • yoshibot/SRB2
  • TehRealSalt/SRB2
  • PrisimaTF/SRB2
  • Hatninja/SRB2
  • SteelT/SRB2
  • james/SRB2
  • ShaderWraith/SRB2
  • SinnamonLat/SRB2
  • mazmazz_/SRB2
  • filpAM/SRB2
  • chaoloveicemdboy/SRB2
  • Whooa21/SRB2
  • Machturne/SRB2
  • Golden/SRB2
  • Tatsuru/SRB2
  • Snu/SRB2
  • Zwip-Zwap_Zapony/SRB2
  • fickleheart/SRB2
  • alphaRexJames/SRB2
  • JJK/SRB2
  • diskpoppy/SRB2
  • Hannu_Hanhi/SRB2
  • ZipperQR/SRB2
  • kays/SRB2
  • spherallic/SRB2
  • Zippy_Zolton/SRB2
  • namiishere/SRB2
  • Ors/SRB2
  • SMS_Alfredo/SRB2
  • sonic_edge/SRB2
  • lavla/SRB2
  • ashi/SRB2
  • X.organic/SRB2
  • Fafabis/SRB2
  • Meziu/SRB2
  • v-rob/SRB2
  • tertu/SRB2
  • bitten2up/SRB2
  • flarn2006/SRB2
  • Krabs/SRB2
  • clairebun/SRB2
  • Lactozilla/SRB2
  • thehackstack/SRB2
  • Spice/SRB2
  • win8linux/SRB2
  • JohnFrostFox/SRB2
  • talktoneon726/SRB2
  • Wane/SRB2
  • Lamibe/SRB2
  • spectrumuk2/srb-2
  • nerdyminer18/srb-2
  • 256nil/SRB2
  • ARJr/SRB2
  • Alam/SRB2
  • Zenya/srb-2-marathon-demos
  • Acelite/srb-2-archivedmodifications
  • MIDIMan/SRB2
  • Lach/SRB2
  • Frostiikin/bounce-tweaks
  • Hanicef/SRB2Classic
  • Jaden/SRB2
  • Tyron/SRB2
  • Astronight/SRB2
  • Mari0shi06/SRB2
  • aiire/SRB2
  • Galactice/SRB2
  • srb2-ports/srb2-dreamcast
  • sdasdas/SRB2
  • chreas/srb-2-vr
  • StarManiaKG/the-story-of-sinically-rocketing-and-botching-the-2nd
  • LoganAir/SRB2
  • NepDisk/srb-2
  • alufolie91/SRB2
  • Felicia.iso/SRB2
  • twi/SRB2
  • BarrelsOFun/SRB2
  • Speed2411/SRB2
  • Leather_Realms/SRB2
  • Ayemar/SRB2
  • Acelite/SRB2
  • VladDoc/SRB2
  • kaldrum/model-features
  • strawberryfox417/SRB2
  • Lugent/SRB2
  • Jisk/SRB2
  • Rem/SRB2
  • Refrag/SRB2
  • Henry_3230/srb-3230
  • TehPuertoRicanSpartan2/tprs-srb2
  • Leminn/srb-2-marathon-stuff
  • chromaticpipe2/SRB2
  • MiguelGustavo15/SRB2
  • Maru/srb-2-tests
  • SilicDev/SRB2
  • UnmatchedBracket/SRB2
  • HybridDog/SRB2
  • xordspar0/SRB2
  • jsjhbewfhh/SRB2
  • Fancy2209/SRB2
  • Lorsoen/SRB2
  • shindoukin/SRB2
  • GamerOfDays/SRB2
  • Craftyawesome/SRB2
  • tenshi-tensai-tennoji/SRB2
  • Scarfdudebalder/SRB2
  • luigi-budd/srb-2-fix-interplag-lockon
  • mskluesner/SRB2
  • johnpetersa19/SRB2
  • Pheazant/SRB2
  • chromaticpipe2/srb2classic
  • romoney5/SRB2
  • PAS/SRB2Classic
  • BlueStaggo/SRB2
118 results
Show changes
Commits on Source (16)
...@@ -52,6 +52,7 @@ p_telept.c ...@@ -52,6 +52,7 @@ p_telept.c
p_tick.c p_tick.c
p_user.c p_user.c
p_slopes.c p_slopes.c
p_world.c
tables.c tables.c
r_bsp.c r_bsp.c
r_data.c r_data.c
......
...@@ -529,6 +529,10 @@ boolean B_CheckRespawn(player_t *player) ...@@ -529,6 +529,10 @@ boolean B_CheckRespawn(player_t *player)
return false; return false;
} }
// Not even in the same world?
if (P_GetMobjWorld(sonic) != P_GetMobjWorld(tails))
return true;
// If you can't see Sonic, I guess we should? // If you can't see Sonic, I guess we should?
if (!P_CheckSight(sonic, tails) && P_AproxDistance(P_AproxDistance(tails->x-sonic->x, tails->y-sonic->y), tails->z-sonic->z) > FixedMul(1024*FRACUNIT, tails->scale)) if (!P_CheckSight(sonic, tails) && P_AproxDistance(P_AproxDistance(tails->x-sonic->x, tails->y-sonic->y), tails->z-sonic->z) > FixedMul(1024*FRACUNIT, tails->scale))
return true; return true;
......
...@@ -1394,9 +1394,9 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime) ...@@ -1394,9 +1394,9 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime)
memset(netbuffer->u.serverinfo.maptitle, 0, sizeof netbuffer->u.serverinfo.maptitle); memset(netbuffer->u.serverinfo.maptitle, 0, sizeof netbuffer->u.serverinfo.maptitle);
if (mapheaderinfo[gamemap-1] && *mapheaderinfo[gamemap-1]->lvlttl) if (worldmapheader && *worldmapheader->lvlttl)
{ {
char *read = mapheaderinfo[gamemap-1]->lvlttl, *writ = netbuffer->u.serverinfo.maptitle; char *read = worldmapheader->lvlttl, *writ = netbuffer->u.serverinfo.maptitle;
while (writ < (netbuffer->u.serverinfo.maptitle+32) && *read != '\0') while (writ < (netbuffer->u.serverinfo.maptitle+32) && *read != '\0')
{ {
if (!(*read & 0x80)) if (!(*read & 0x80))
...@@ -1407,18 +1407,18 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime) ...@@ -1407,18 +1407,18 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime)
read++; read++;
} }
*writ = '\0'; *writ = '\0';
//strncpy(netbuffer->u.serverinfo.maptitle, (char *)mapheaderinfo[gamemap-1]->lvlttl, 33); //strncpy(netbuffer->u.serverinfo.maptitle, (char *)worldmapheader->lvlttl, 33);
} }
else else
strncpy(netbuffer->u.serverinfo.maptitle, "UNKNOWN", 32); strncpy(netbuffer->u.serverinfo.maptitle, "UNKNOWN", 32);
if (mapheaderinfo[gamemap-1] && !(mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE)) if (worldmapheader && !(worldmapheader->levelflags & LF_NOZONE))
netbuffer->u.serverinfo.iszone = 1; netbuffer->u.serverinfo.iszone = 1;
else else
netbuffer->u.serverinfo.iszone = 0; netbuffer->u.serverinfo.iszone = 0;
if (mapheaderinfo[gamemap-1]) if (worldmapheader)
netbuffer->u.serverinfo.actnum = mapheaderinfo[gamemap-1]->actnum; netbuffer->u.serverinfo.actnum = worldmapheader->actnum;
p = PutFileNeeded(0); p = PutFileNeeded(0);
...@@ -1540,7 +1540,7 @@ static boolean SV_SendServerConfig(INT32 node) ...@@ -1540,7 +1540,7 @@ static boolean SV_SendServerConfig(INT32 node)
} }
#ifndef NONET #ifndef NONET
#define SAVEGAMESIZE (768*1024) #define SAVEGAMESIZE (8192*1024) // was (768*1024)
static boolean SV_ResendingSavegameToAnyone(void) static boolean SV_ResendingSavegameToAnyone(void)
{ {
...@@ -1706,12 +1706,12 @@ static void CL_LoadReceivedSavegame(boolean reloading) ...@@ -1706,12 +1706,12 @@ static void CL_LoadReceivedSavegame(boolean reloading)
// load a base level // load a base level
if (P_LoadNetGame(reloading)) if (P_LoadNetGame(reloading))
{ {
const UINT8 actnum = mapheaderinfo[gamemap-1]->actnum; const UINT8 actnum = worldmapheader->actnum;
CONS_Printf(M_GetText("Map is now \"%s"), G_BuildMapName(gamemap)); CONS_Printf(M_GetText("Map is now \"%s"), G_BuildMapName(gamemap));
if (strcmp(mapheaderinfo[gamemap-1]->lvlttl, "")) if (strcmp(worldmapheader->lvlttl, ""))
{ {
CONS_Printf(": %s", mapheaderinfo[gamemap-1]->lvlttl); CONS_Printf(": %s", worldmapheader->lvlttl);
if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE)) if (!(worldmapheader->levelflags & LF_NOZONE))
CONS_Printf(M_GetText(" Zone")); CONS_Printf(M_GetText(" Zone"));
if (actnum > 0) if (actnum > 0)
CONS_Printf(" %2d", actnum); CONS_Printf(" %2d", actnum);
...@@ -2885,6 +2885,9 @@ void CL_RemovePlayer(INT32 playernum, kickreason_t reason) ...@@ -2885,6 +2885,9 @@ void CL_RemovePlayer(INT32 playernum, kickreason_t reason)
} }
} }
if (players[playernum].world)
((world_t *)players[playernum].world)->players--;
if (gametyperules & GTR_TEAMFLAGS) if (gametyperules & GTR_TEAMFLAGS)
P_PlayerFlagBurst(&players[playernum], false); // Don't take the flag with you! P_PlayerFlagBurst(&players[playernum], false); // Don't take the flag with you!
......
...@@ -342,7 +342,7 @@ typedef struct ...@@ -342,7 +342,7 @@ typedef struct
extern serverelem_t serverlist[MAXSERVERLIST]; extern serverelem_t serverlist[MAXSERVERLIST];
extern UINT32 serverlistcount; extern UINT32 serverlistcount;
extern INT32 mapchangepending; extern boolean mapchangepending;
// Points inside doomcom // Points inside doomcom
extern doomdata_t *netbuffer; extern doomdata_t *netbuffer;
......
...@@ -298,6 +298,31 @@ gamestate_t wipegamestate = GS_LEVEL; ...@@ -298,6 +298,31 @@ gamestate_t wipegamestate = GS_LEVEL;
INT16 wipetypepre = -1; INT16 wipetypepre = -1;
INT16 wipetypepost = -1; INT16 wipetypepost = -1;
static void D_RenderView(UINT32 viewnum)
{
player_t *player = viewnum == 1 ? &players[secondarydisplayplayer] : &players[displayplayer];
R_PrepareViewWorld(player);
if (viewworld == NULL)
return;
R_ApplyLevelInterpolators(viewworld, R_UsingFrameInterpolation() ? rendertimefrac : FRACUNIT);
if (player->mo || player->playerstate == PST_DEAD)
{
R_SetViewNum(viewnum);
#ifdef HWRENDER
if (rendermode != render_soft)
HWR_RenderPlayerView(viewnum, player);
else
#endif
if (rendermode != render_none)
R_RenderPlayerView(player);
}
}
static void D_Display(void) static void D_Display(void)
{ {
boolean forcerefresh = false; boolean forcerefresh = false;
...@@ -478,41 +503,19 @@ static void D_Display(void) ...@@ -478,41 +503,19 @@ static void D_Display(void)
if (!automapactive && !dedicated && cv_renderview.value) if (!automapactive && !dedicated && cv_renderview.value)
{ {
R_ApplyLevelInterpolators(R_UsingFrameInterpolation() ? rendertimefrac : FRACUNIT);
PS_START_TIMING(ps_rendercalltime); PS_START_TIMING(ps_rendercalltime);
if (players[displayplayer].mo || players[displayplayer].playerstate == PST_DEAD) objectsdrawn = 0;
{
topleft = screens[0] + viewwindowy*vid.width + viewwindowx;
objectsdrawn = 0;
#ifdef HWRENDER
if (rendermode != render_soft)
HWR_RenderPlayerView(0, &players[displayplayer]);
else
#endif
if (rendermode != render_none)
R_RenderPlayerView(&players[displayplayer]);
}
// render the second screen
if (splitscreen && players[secondarydisplayplayer].mo)
{
#ifdef HWRENDER
if (rendermode != render_soft)
HWR_RenderPlayerView(1, &players[secondarydisplayplayer]);
else
#endif
if (rendermode != render_none)
{
viewwindowy = vid.height / 2;
M_Memcpy(ylookup, ylookup2, viewheight*sizeof (ylookup[0]));
topleft = screens[0] + viewwindowy*vid.width + viewwindowx; D_RenderView(0);
R_RenderPlayerView(&players[secondarydisplayplayer]); // render the second screen
if (splitscreen)
D_RenderView(1);
viewwindowy = 0; for (INT32 wi = 0; wi < numworlds; wi++)
M_Memcpy(ylookup, ylookup1, viewheight*sizeof (ylookup[0])); {
} R_RestoreLevelInterpolators(worldlist[wi]);
worldlist[wi]->interpolated_level_this_frame = false;
} }
// Image postprocessing effect // Image postprocessing effect
...@@ -527,7 +530,6 @@ static void D_Display(void) ...@@ -527,7 +530,6 @@ static void D_Display(void)
V_DoPostProcessor(1, postimgtype2, postimgparam2); V_DoPostProcessor(1, postimgtype2, postimgparam2);
} }
PS_STOP_TIMING(ps_rendercalltime); PS_STOP_TIMING(ps_rendercalltime);
R_RestoreLevelInterpolators();
} }
if (lastdraw) if (lastdraw)
......
...@@ -64,7 +64,9 @@ ...@@ -64,7 +64,9 @@
static void Got_NameAndColor(UINT8 **cp, INT32 playernum); static void Got_NameAndColor(UINT8 **cp, INT32 playernum);
static void Got_WeaponPref(UINT8 **cp, INT32 playernum); static void Got_WeaponPref(UINT8 **cp, INT32 playernum);
static void Got_Mapcmd(UINT8 **cp, INT32 playernum); static void Got_Mapcmd(UINT8 **cp, INT32 playernum);
static void Got_Newworld(UINT8 **cp, INT32 playernum);
static void Got_ExitLevelcmd(UINT8 **cp, INT32 playernum); static void Got_ExitLevelcmd(UINT8 **cp, INT32 playernum);
static void Got_Switchworld(UINT8 **cp, INT32 playernum);
static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum); static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum);
static void Got_RequestAddfoldercmd(UINT8 **cp, INT32 playernum); static void Got_RequestAddfoldercmd(UINT8 **cp, INT32 playernum);
static void Got_Addfilecmd(UINT8 **cp, INT32 playernum); static void Got_Addfilecmd(UINT8 **cp, INT32 playernum);
...@@ -416,6 +418,7 @@ const char *netxcmdnames[MAXNETXCMD - 1] = ...@@ -416,6 +418,7 @@ const char *netxcmdnames[MAXNETXCMD - 1] =
"ADDPLAYER", "ADDPLAYER",
"TEAMCHANGE", "TEAMCHANGE",
"CLEARSCORES", "CLEARSCORES",
"SWITCHWORLD",
"VERIFIED", "VERIFIED",
"RANDOMSEED", "RANDOMSEED",
"RUNSOC", "RUNSOC",
...@@ -452,7 +455,9 @@ void D_RegisterServerCommands(void) ...@@ -452,7 +455,9 @@ void D_RegisterServerCommands(void)
RegisterNetXCmd(XD_NAMEANDCOLOR, Got_NameAndColor); RegisterNetXCmd(XD_NAMEANDCOLOR, Got_NameAndColor);
RegisterNetXCmd(XD_WEAPONPREF, Got_WeaponPref); RegisterNetXCmd(XD_WEAPONPREF, Got_WeaponPref);
RegisterNetXCmd(XD_MAP, Got_Mapcmd); RegisterNetXCmd(XD_MAP, Got_Mapcmd);
RegisterNetXCmd(XD_NEWWORLD, Got_Newworld);
RegisterNetXCmd(XD_EXITLEVEL, Got_ExitLevelcmd); RegisterNetXCmd(XD_EXITLEVEL, Got_ExitLevelcmd);
RegisterNetXCmd(XD_SWITCHWORLD, Got_Switchworld);
RegisterNetXCmd(XD_ADDFILE, Got_Addfilecmd); RegisterNetXCmd(XD_ADDFILE, Got_Addfilecmd);
RegisterNetXCmd(XD_ADDFOLDER, Got_Addfoldercmd); RegisterNetXCmd(XD_ADDFOLDER, Got_Addfoldercmd);
RegisterNetXCmd(XD_REQADDFILE, Got_RequestAddfilecmd); RegisterNetXCmd(XD_REQADDFILE, Got_RequestAddfilecmd);
...@@ -480,6 +485,8 @@ void D_RegisterServerCommands(void) ...@@ -480,6 +485,8 @@ void D_RegisterServerCommands(void)
RegisterNetXCmd(XD_CLEARSCORES, Got_Clearscores); RegisterNetXCmd(XD_CLEARSCORES, Got_Clearscores);
COM_AddCommand("clearscores", Command_Clearscores_f, COM_LUA); COM_AddCommand("clearscores", Command_Clearscores_f, COM_LUA);
COM_AddCommand("map", Command_Map_f, COM_LUA); COM_AddCommand("map", Command_Map_f, COM_LUA);
COM_AddCommand("switchworld", Command_Switchworld_f, COM_LUA);
COM_AddCommand("listworlds", Command_Listworlds_f, COM_LUA);
COM_AddCommand("exitgame", Command_ExitGame_f, COM_LUA); COM_AddCommand("exitgame", Command_ExitGame_f, COM_LUA);
COM_AddCommand("retry", Command_Retry_f, COM_LUA); COM_AddCommand("retry", Command_Retry_f, COM_LUA);
...@@ -1158,7 +1165,7 @@ UINT8 CanChangeSkin(INT32 playernum) ...@@ -1158,7 +1165,7 @@ UINT8 CanChangeSkin(INT32 playernum)
return true; return true;
// Force skin in effect. // Force skin in effect.
if ((cv_forceskin.value != -1) || (mapheaderinfo[gamemap-1] && mapheaderinfo[gamemap-1]->forcecharacter[0] != '\0')) if ((cv_forceskin.value != -1) || (worldmapheader && worldmapheader->forcecharacter[0] != '\0'))
return false; return false;
// Can change skin in intermission and whatnot. // Can change skin in intermission and whatnot.
...@@ -1728,7 +1735,7 @@ static void Command_StopMovie_f(void) ...@@ -1728,7 +1735,7 @@ static void Command_StopMovie_f(void)
M_StopMovie(); M_StopMovie();
} }
INT32 mapchangepending = 0; boolean mapchangepending = false;
/** Runs a map change. /** Runs a map change.
* The supplied data are assumed to be good. If provided by a user, they will * The supplied data are assumed to be good. If provided by a user, they will
...@@ -1812,10 +1819,11 @@ void D_MapChange(INT32 mapnum, INT32 newgametype, boolean pultmode, boolean rese ...@@ -1812,10 +1819,11 @@ void D_MapChange(INT32 mapnum, INT32 newgametype, boolean pultmode, boolean rese
} }
if (delay == 1) if (delay == 1)
mapchangepending = 1; mapchangepending = true;
else else
{ {
mapchangepending = 0; mapchangepending = false;
// spawn the server if needed // spawn the server if needed
// reset players if there is a new one // reset players if there is a new one
if (!IsPlayerAdmin(consoleplayer)) if (!IsPlayerAdmin(consoleplayer))
...@@ -1833,6 +1841,22 @@ void D_MapChange(INT32 mapnum, INT32 newgametype, boolean pultmode, boolean rese ...@@ -1833,6 +1841,22 @@ void D_MapChange(INT32 mapnum, INT32 newgametype, boolean pultmode, boolean rese
} }
} }
// Sends a command to add a new world.
// It's as simple as that.
void D_AddWorld(INT32 mapnum)
{
char buf[MAX_WADPATH+1];
char *buf_p = buf;
CONS_Debug(DBG_GAMELOGIC, "New world: mapnum=%d\n", mapnum);
I_Assert(W_CheckNumForName(mapname) != LUMPERROR);
WRITESTRINGN(buf_p, G_BuildMapName(mapnum), MAX_WADPATH);
SendNetXCmd(XD_NEWWORLD, buf, buf_p - buf);
}
static char * static char *
ConcatCommandArgv (int start, int end) ConcatCommandArgv (int start, int end)
{ {
...@@ -1893,7 +1917,9 @@ static void Command_Map_f(void) ...@@ -1893,7 +1917,9 @@ static void Command_Map_f(void)
INT32 d; INT32 d;
if (client && !IsPlayerAdmin(consoleplayer)) boolean addworld = COM_CheckParm("-addworld");
if (client && !addworld && !IsPlayerAdmin(consoleplayer))
{ {
CONS_Printf(M_GetText("Only the server or a remote admin can use this.\n")); CONS_Printf(M_GetText("Only the server or a remote admin can use this.\n"));
return; return;
...@@ -2058,7 +2084,10 @@ static void Command_Map_f(void) ...@@ -2058,7 +2084,10 @@ static void Command_Map_f(void)
} }
tutorialmode = false; // warping takes us out of tutorial mode tutorialmode = false; // warping takes us out of tutorial mode
D_MapChange(newmapnum, newgametype, false, newresetplayers, 0, false, fromlevelselect); if (addworld)
D_AddWorld(newmapnum);
else
D_MapChange(newmapnum, newgametype, false, newresetplayers, 0, false, fromlevelselect);
Z_Free(realmapname); Z_Free(realmapname);
} }
...@@ -2078,6 +2107,8 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum) ...@@ -2078,6 +2107,8 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum)
UINT8 skipprecutscene, FLS; UINT8 skipprecutscene, FLS;
INT16 mapnumber; INT16 mapnumber;
flags = READUINT8(*cp);
if (playernum != serverplayer && !IsPlayerAdmin(playernum)) if (playernum != serverplayer && !IsPlayerAdmin(playernum))
{ {
CONS_Alert(CONS_WARNING, M_GetText("Illegal map change received from %s\n"), player_names[playernum]); CONS_Alert(CONS_WARNING, M_GetText("Illegal map change received from %s\n"), player_names[playernum]);
...@@ -2089,8 +2120,6 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum) ...@@ -2089,8 +2120,6 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum)
if (chmappending) if (chmappending)
chmappending--; chmappending--;
flags = READUINT8(*cp);
ultimatemode = ((flags & 1) != 0); ultimatemode = ((flags & 1) != 0);
if (netgame || multiplayer) if (netgame || multiplayer)
ultimatemode = false; ultimatemode = false;
...@@ -2141,7 +2170,7 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum) ...@@ -2141,7 +2170,7 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum)
mapnumber = M_MapNumber(mapname[3], mapname[4]); mapnumber = M_MapNumber(mapname[3], mapname[4]);
LUA_HookInt(mapnumber, HOOK(MapChange)); LUA_HookInt(mapnumber, HOOK(MapChange));
G_InitNew(ultimatemode, mapname, resetplayer, skipprecutscene, FLS); G_InitNew(mapname, ultimatemode, resetplayer, skipprecutscene, FLS);
if (demoplayback && !timingdemo) if (demoplayback && !timingdemo)
precache = true; precache = true;
if (timingdemo) if (timingdemo)
...@@ -2154,6 +2183,97 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum) ...@@ -2154,6 +2183,97 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum)
demo_start = true; demo_start = true;
} }
/** Receives a new world command and creates a new one.
*
* \param cp Data buffer.
* \param playernum Player number responsible for the message.
* \sa D_MapChange
*/
static void Got_Newworld(UINT8 **cp, INT32 playernum)
{
(void)playernum;
char mapname[MAX_WADPATH+1];
READSTRINGN(*cp, mapname, MAX_WADPATH);
DEBFILE(va("Adding world with map %s\n", mapname));
G_LoadWorld(mapname);
}
void SendWorldSwitch(INT32 worldnum, void *location, boolean nodetach)
{
UINT8 buf[sizeof(INT32) + sizeof(UINT8) + (sizeof(fixed_t) * 3) + sizeof(angle_t)];
UINT8 *p = buf;
UINT8 flags = 0;
if (location != NULL)
flags |= 1;
if (nodetach)
flags |= 2;
WRITEINT32(p, worldnum);
WRITEUINT8(p, flags);
if (flags & 1)
{
location_t *loc = (location_t *)location;
WRITEFIXED(p, loc->x);
WRITEFIXED(p, loc->y);
WRITEFIXED(p, loc->z);
WRITEANGLE(p, loc->angle);
}
else
{
WRITEFIXED(p, 0);
WRITEFIXED(p, 0);
WRITEFIXED(p, 0);
WRITEANGLE(p, 0);
}
SendNetXCmd(XD_SWITCHWORLD, buf, sizeof(buf));
}
static void Got_Switchworld(UINT8 **cp, INT32 playernum)
{
player_t *player = &players[playernum];
INT32 worldnum = READINT32(*cp);
UINT8 flags = READUINT8(*cp);
location_t location;
location.x = READFIXED(*cp);
location.y = READFIXED(*cp);
location.z = READFIXED(*cp);
location.angle = READANGLE(*cp);
if (worldnum >= numworlds)
{
CONS_Alert(CONS_WARNING, M_GetText("Illegal world switch command received from %s\n"), player_names[playernum]);
if (server)
SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY);
return;
}
// Don't detach from the current world, if any
if (flags & 2)
{
world_t *w = player->world;
if (w != NULL)
w->players--;
player->world = NULL;
}
if (flags & 1)
{
P_SwitchWorld(player, worldlist[worldnum], &location);
}
else
{
P_SwitchWorld(player, worldlist[worldnum], NULL);
}
}
static void Command_Pause(void) static void Command_Pause(void)
{ {
UINT8 buf[2]; UINT8 buf[2];
...@@ -4329,7 +4449,8 @@ static void Gravity_OnChange(void) ...@@ -4329,7 +4449,8 @@ static void Gravity_OnChange(void)
if (!CV_IsSetToDefault(&cv_gravity)) if (!CV_IsSetToDefault(&cv_gravity))
G_SetUsedCheats(false); G_SetUsedCheats(false);
gravity = cv_gravity.value; if (world)
world->gravity = cv_gravity.value;
} }
static void SoundTest_OnChange(void) static void SoundTest_OnChange(void)
...@@ -4522,10 +4643,10 @@ static void Command_Showmap_f(void) ...@@ -4522,10 +4643,10 @@ static void Command_Showmap_f(void)
{ {
if (gamestate == GS_LEVEL) if (gamestate == GS_LEVEL)
{ {
if (mapheaderinfo[gamemap-1]->actnum) if (worldmapheader->actnum)
CONS_Printf("%s (%d): %s %d\n", G_BuildMapName(gamemap), gamemap, mapheaderinfo[gamemap-1]->lvlttl, mapheaderinfo[gamemap-1]->actnum); CONS_Printf("%s (%d): %s %d\n", G_BuildMapName(gamemap), gamemap, worldmapheader->lvlttl, worldmapheader->actnum);
else else
CONS_Printf("%s (%d): %s\n", G_BuildMapName(gamemap), gamemap, mapheaderinfo[gamemap-1]->lvlttl); CONS_Printf("%s (%d): %s\n", G_BuildMapName(gamemap), gamemap, worldmapheader->lvlttl);
} }
else else
CONS_Printf(M_GetText("You must be in a level to use this.\n")); CONS_Printf(M_GetText("You must be in a level to use this.\n"));
......
...@@ -130,23 +130,25 @@ typedef enum ...@@ -130,23 +130,25 @@ typedef enum
XD_SAY, // 5 XD_SAY, // 5
XD_MAP, // 6 XD_MAP, // 6
XD_EXITLEVEL, // 7 XD_EXITLEVEL, // 7
XD_ADDFILE, // 8 XD_NEWWORLD, // 8
XD_ADDFOLDER, // 9 XD_SWITCHWORLD, // 9
XD_PAUSE, // 10 XD_ADDFILE, // 10
XD_ADDPLAYER, // 11 XD_ADDFOLDER, // 11
XD_TEAMCHANGE, // 12 XD_PAUSE, // 12
XD_CLEARSCORES, // 13 XD_ADDPLAYER, // 13
XD_VERIFIED, // 14 XD_TEAMCHANGE, // 14
XD_RANDOMSEED, // 15 XD_CLEARSCORES, // 15
XD_RUNSOC, // 16 XD_VERIFIED, // 16
XD_REQADDFILE, // 17 XD_RANDOMSEED, // 17
XD_REQADDFOLDER,// 18 XD_RUNSOC, // 18
XD_SETMOTD, // 19 XD_REQADDFILE, // 19
XD_SUICIDE, // 20 XD_REQADDFOLDER,// 20
XD_DEMOTED, // 21 XD_SETMOTD, // 21
XD_LUACMD, // 22 XD_SUICIDE, // 22
XD_LUAVAR, // 23 XD_DEMOTED, // 23
XD_LUAFILE, // 24 XD_LUACMD, // 24
XD_LUAVAR, // 25
XD_LUAFILE, // 26
MAXNETXCMD MAXNETXCMD
} netxcmd_t; } netxcmd_t;
...@@ -202,12 +204,14 @@ void Command_ExitGame_f(void); ...@@ -202,12 +204,14 @@ void Command_ExitGame_f(void);
void Command_Retry_f(void); void Command_Retry_f(void);
void D_GameTypeChanged(INT32 lastgametype); // not a real _OnChange function anymore void D_GameTypeChanged(INT32 lastgametype); // not a real _OnChange function anymore
void D_MapChange(INT32 pmapnum, INT32 pgametype, boolean pultmode, boolean presetplayers, INT32 pdelay, boolean pskipprecutscene, boolean pfromlevelselect); void D_MapChange(INT32 pmapnum, INT32 pgametype, boolean pultmode, boolean presetplayers, INT32 pdelay, boolean pskipprecutscene, boolean pfromlevelselect);
void D_AddWorld(INT32 pmapnum);
boolean IsPlayerAdmin(INT32 playernum); boolean IsPlayerAdmin(INT32 playernum);
void SetAdminPlayer(INT32 playernum); void SetAdminPlayer(INT32 playernum);
void ClearAdminPlayers(void); void ClearAdminPlayers(void);
void RemoveAdminPlayer(INT32 playernum); void RemoveAdminPlayer(INT32 playernum);
void ItemFinder_OnChange(void); void ItemFinder_OnChange(void);
void D_SetPassword(const char *pw); void D_SetPassword(const char *pw);
void SendWorldSwitch(INT32 worldnum, void *location, boolean nodetach);
// used for the player setup menu // used for the player setup menu
UINT8 CanChangeSkin(INT32 playernum); UINT8 CanChangeSkin(INT32 playernum);
......
...@@ -360,6 +360,9 @@ typedef struct player_s ...@@ -360,6 +360,9 @@ typedef struct player_s
playerstate_t playerstate; playerstate_t playerstate;
void *world;
INT32 worldnum; // Lactozilla: for unarchiving purposes only, just like mobjnum
// Determine POV, including viewpoint bobbing during movement. // Determine POV, including viewpoint bobbing during movement.
fixed_t camerascale; fixed_t camerascale;
fixed_t shieldscale; fixed_t shieldscale;
......
...@@ -403,6 +403,10 @@ extern skincolor_t skincolors[MAXSKINCOLORS]; ...@@ -403,6 +403,10 @@ extern skincolor_t skincolors[MAXSKINCOLORS];
#define PUSHACCEL (2*FRACUNIT) // Acceleration for MF2_SLIDEPUSH items. #define PUSHACCEL (2*FRACUNIT) // Acceleration for MF2_SLIDEPUSH items.
// Time interval for item respawning.
// WARNING MUST be a power of 2
#define ITEMQUESIZE 1024
// Special linedef executor tag numbers! Binary map format only (UDMF has other ways of doing these things). // Special linedef executor tag numbers! Binary map format only (UDMF has other ways of doing these things).
enum { enum {
LE_PINCHPHASE = -2, // A boss entered pinch phase (and, in most cases, is preparing their pinch phase attack!) LE_PINCHPHASE = -2, // A boss entered pinch phase (and, in most cases, is preparing their pinch phase attack!)
...@@ -632,13 +636,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; ...@@ -632,13 +636,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch;
/// Experimental attempts at preventing MF_PAPERCOLLISION objects from getting stuck in walls. /// Experimental attempts at preventing MF_PAPERCOLLISION objects from getting stuck in walls.
//#define PAPER_COLLISIONCORRECTION //#define PAPER_COLLISIONCORRECTION
/// FINALLY some real clipping that doesn't make walls dissappear AND speeds the game up
/// (that was the original comment from SRB2CB, sadly it is a lie and actually slows game down)
/// on the bright side it fixes some weird issues with translucent walls
/// \note SRB2CB port.
/// SRB2CB itself ported this from PrBoom+
#define NEWCLIP
/// OpenGL shaders /// OpenGL shaders
#define GL_SHADERS #define GL_SHADERS
......
...@@ -40,7 +40,6 @@ extern UINT32 mapmusposition; ...@@ -40,7 +40,6 @@ extern UINT32 mapmusposition;
// Use other bits if necessary. // Use other bits if necessary.
extern UINT32 maptol; extern UINT32 maptol;
extern UINT8 globalweather;
extern INT32 curWeather; extern INT32 curWeather;
extern INT32 cursaveslot; extern INT32 cursaveslot;
//extern INT16 lastmapsaved; //extern INT16 lastmapsaved;
...@@ -389,6 +388,10 @@ typedef struct ...@@ -389,6 +388,10 @@ typedef struct
extern mapheader_t* mapheaderinfo[NUMMAPS]; extern mapheader_t* mapheaderinfo[NUMMAPS];
extern mapheader_t* curmapheader;
extern mapheader_t* nextmapheader;
extern mapheader_t* worldmapheader;
// Gametypes // Gametypes
#define NUMGAMETYPEFREESLOTS 128 #define NUMGAMETYPEFREESLOTS 128
enum GameType enum GameType
...@@ -549,14 +552,12 @@ extern UINT8 useContinues; ...@@ -549,14 +552,12 @@ extern UINT8 useContinues;
extern UINT8 shareEmblems; extern UINT8 shareEmblems;
extern mobj_t *hunt1, *hunt2, *hunt3; // Emerald hunt locations #define NUM_EMERALD_HUNT_LOCATIONS 3
// For racing // For racing
extern UINT32 countdown; extern UINT32 countdown;
extern UINT32 countdown2; extern UINT32 countdown2;
extern fixed_t gravity;
//for CTF balancing //for CTF balancing
extern INT16 autobalance; extern INT16 autobalance;
extern INT16 teamscramble; extern INT16 teamscramble;
...@@ -579,16 +580,6 @@ extern tic_t hidetime; ...@@ -579,16 +580,6 @@ extern tic_t hidetime;
extern tic_t gametic; extern tic_t gametic;
#define localgametic leveltime #define localgametic leveltime
// Player spawn spots.
extern mapthing_t *playerstarts[MAXPLAYERS]; // Cooperative
extern mapthing_t *bluectfstarts[MAXPLAYERS]; // CTF
extern mapthing_t *redctfstarts[MAXPLAYERS]; // CTF
#define WAYPOINTSEQUENCESIZE 256
#define NUMWAYPOINTSEQUENCES 256
extern mobj_t *waypoints[NUMWAYPOINTSEQUENCES][WAYPOINTSEQUENCESIZE];
extern UINT16 numwaypoints[NUMWAYPOINTSEQUENCES];
void P_AddWaypoint(UINT8 sequence, UINT8 id, mobj_t *waypoint); void P_AddWaypoint(UINT8 sequence, UINT8 id, mobj_t *waypoint);
mobj_t *P_GetFirstWaypoint(UINT8 sequence); mobj_t *P_GetFirstWaypoint(UINT8 sequence);
mobj_t *P_GetLastWaypoint(UINT8 sequence); mobj_t *P_GetLastWaypoint(UINT8 sequence);
......
...@@ -2429,8 +2429,11 @@ void F_StartTitleScreen(void) ...@@ -2429,8 +2429,11 @@ void F_StartTitleScreen(void)
if (!mapheaderinfo[gamemap-1]) if (!mapheaderinfo[gamemap-1])
P_AllocMapHeader(gamemap-1); P_AllocMapHeader(gamemap-1);
maptol = mapheaderinfo[gamemap-1]->typeoflevel; World_UnloadAll();
globalweather = mapheaderinfo[gamemap-1]->weather;
curmapheader = nextmapheader = mapheaderinfo[gamemap-1];
worldmapheader = curmapheader;
maptol = curmapheader->typeoflevel;
G_DoLoadLevel(true); G_DoLoadLevel(true);
if (!titlemap) if (!titlemap)
...@@ -2439,10 +2442,10 @@ void F_StartTitleScreen(void) ...@@ -2439,10 +2442,10 @@ void F_StartTitleScreen(void)
players[displayplayer].playerstate = PST_DEAD; // Don't spawn the player in dummy (I'm still a filthy cheater) players[displayplayer].playerstate = PST_DEAD; // Don't spawn the player in dummy (I'm still a filthy cheater)
// Set Default Position // Set Default Position
if (playerstarts[0]) if (world->playerstarts[0])
startpos = playerstarts[0]; startpos = world->playerstarts[0];
else if (deathmatchstarts[0]) else if (world->deathmatchstarts[0])
startpos = deathmatchstarts[0]; startpos = world->deathmatchstarts[0];
else else
startpos = NULL; startpos = NULL;
...@@ -2476,6 +2479,8 @@ void F_StartTitleScreen(void) ...@@ -2476,6 +2479,8 @@ void F_StartTitleScreen(void)
gamemap = 1; // g_game.c gamemap = 1; // g_game.c
if (!mapheaderinfo[gamemap-1]) if (!mapheaderinfo[gamemap-1])
P_AllocMapHeader(gamemap-1); P_AllocMapHeader(gamemap-1);
curmapheader = nextmapheader = mapheaderinfo[gamemap-1];
worldmapheader = curmapheader;
CON_ClearHUD(); CON_ClearHUD();
} }
......
...@@ -1868,6 +1868,8 @@ void G_DoPlayDemo(char *defdemoname) ...@@ -1868,6 +1868,8 @@ void G_DoPlayDemo(char *defdemoname)
} }
demo_p += 4; // "PLAY" demo_p += 4; // "PLAY"
gamemap = READINT16(demo_p); gamemap = READINT16(demo_p);
curmapheader = nextmapheader = mapheaderinfo[gamemap-1];
worldmapheader = curmapheader;
demo_p += 16; // mapmd5 demo_p += 16; // mapmd5
demoflags = READUINT8(demo_p); demoflags = READUINT8(demo_p);
...@@ -1983,7 +1985,7 @@ void G_DoPlayDemo(char *defdemoname) ...@@ -1983,7 +1985,7 @@ void G_DoPlayDemo(char *defdemoname)
memset(playeringame,0,sizeof(playeringame)); memset(playeringame,0,sizeof(playeringame));
playeringame[0] = true; playeringame[0] = true;
P_SetRandSeed(randseed); P_SetRandSeed(randseed);
G_InitNew(false, G_BuildMapName(gamemap), true, true, false); G_InitNew(G_BuildMapName(gamemap), false, true, true, false);
// Set color // Set color
players[0].skincolor = skins[players[0].skin].prefcolor; players[0].skincolor = skins[players[0].skin].prefcolor;
...@@ -2213,7 +2215,7 @@ void G_AddGhost(char *defdemoname) ...@@ -2213,7 +2215,7 @@ void G_AddGhost(char *defdemoname)
ghosts = gh; ghosts = gh;
gh->version = ghostversion; gh->version = ghostversion;
mthing = playerstarts[0]; mthing = world->playerstarts[0];
I_Assert(mthing); I_Assert(mthing);
{ // A bit more complex than P_SpawnPlayer because ghosts aren't solid and won't just push themselves out of the ceiling. { // A bit more complex than P_SpawnPlayer because ghosts aren't solid and won't just push themselves out of the ceiling.
fixed_t z,f,c; fixed_t z,f,c;
......
This diff is collapsed.
...@@ -136,8 +136,7 @@ extern INT32 localaiming, localaiming2; // should be an angle_t but signed ...@@ -136,8 +136,7 @@ extern INT32 localaiming, localaiming2; // should be an angle_t but signed
void G_ChangePlayerReferences(mobj_t *oldmo, mobj_t *newmo); void G_ChangePlayerReferences(mobj_t *oldmo, mobj_t *newmo);
void G_DoReborn(INT32 playernum); void G_DoReborn(INT32 playernum);
void G_PlayerReborn(INT32 player, boolean betweenmaps); void G_PlayerReborn(INT32 player, boolean betweenmaps);
void G_InitNew(UINT8 pultmode, const char *mapname, boolean resetplayer, void G_InitNew(const char *mapname, UINT8 pultmode, boolean resetplayer, boolean skipprecutscene, boolean FLS);
boolean skipprecutscene, boolean FLS);
char *G_BuildMapTitle(INT32 mapnum); char *G_BuildMapTitle(INT32 mapnum);
struct searchdim struct searchdim
...@@ -165,18 +164,21 @@ void G_FreeMapSearch(mapsearchfreq_t *freq, INT32 freqc); ...@@ -165,18 +164,21 @@ void G_FreeMapSearch(mapsearchfreq_t *freq, INT32 freqc);
INT32 G_FindMapByNameOrCode(const char *query, char **foundmapnamep); INT32 G_FindMapByNameOrCode(const char *query, char **foundmapnamep);
// XMOD spawning // XMOD spawning
mapthing_t *G_FindCTFStart(INT32 playernum); mapthing_t *G_FindCTFStart(void *wptr, INT32 playernum);
mapthing_t *G_FindMatchStart(INT32 playernum); mapthing_t *G_FindMatchStart(void *wptr, INT32 playernum);
mapthing_t *G_FindCoopStart(INT32 playernum); mapthing_t *G_FindCoopStart(void *wptr, INT32 playernum);
mapthing_t *G_FindMapStart(INT32 playernum); mapthing_t *G_FindMapStart(void *wptr, INT32 playernum);
mapthing_t *G_GetMapStartForPlayerNum(void *wptr, INT32 playernum);
void G_MovePlayerToSpawnOrStarpost(INT32 playernum); void G_MovePlayerToSpawnOrStarpost(INT32 playernum);
void G_SpawnPlayer(INT32 playernum); void G_SpawnPlayer(INT32 playernum);
// Can be called by the startup code or M_Responder. // Can be called by the startup code or M_Responder.
// A normal game starts at map 1, but a warp test can start elsewhere // A normal game starts at map 1, but a warp test can start elsewhere
void G_DeferedInitNew(boolean pultmode, const char *mapname, INT32 pickedchar, void G_DeferedInitNew(boolean pultmode, const char *mapname, INT32 pickedchar,boolean SSSG, boolean FLS);
boolean SSSG, boolean FLS);
void G_DoLoadLevel(boolean resetplayer); void G_DoLoadLevel(boolean resetplayer);
boolean G_LoadWorld(const char *mapname);
void G_StartTitleCard(void); void G_StartTitleCard(void);
void G_PreLevelTitleCard(void); void G_PreLevelTitleCard(void);
boolean G_IsTitleCardAvailable(void); boolean G_IsTitleCardAvailable(void);
...@@ -217,6 +219,8 @@ boolean G_CompetitionGametype(void); ...@@ -217,6 +219,8 @@ boolean G_CompetitionGametype(void);
boolean G_EnoughPlayersFinished(void); boolean G_EnoughPlayersFinished(void);
void G_ExitLevel(void); void G_ExitLevel(void);
void G_NextLevel(void); void G_NextLevel(void);
void G_SetNextMap(boolean usespec, boolean inspec);
void G_PlayerFinishLevel(INT32 player);
void G_Continue(void); void G_Continue(void);
void G_UseContinue(void); void G_UseContinue(void);
void G_AfterIntermission(void); void G_AfterIntermission(void);
......
...@@ -54,6 +54,7 @@ typedef enum ...@@ -54,6 +54,7 @@ typedef enum
extern gamestate_t gamestate; extern gamestate_t gamestate;
extern UINT8 titlemapinaction; extern UINT8 titlemapinaction;
extern UINT8 ultimatemode; // was sk_insane extern UINT8 ultimatemode; // was sk_insane
extern boolean roaming;
extern gameaction_t gameaction; extern gameaction_t gameaction;
extern boolean botingame; extern boolean botingame;
......
...@@ -23,17 +23,15 @@ ...@@ -23,17 +23,15 @@
#include "../i_video.h" #include "../i_video.h"
#include "../w_wad.h" #include "../w_wad.h"
#include "../p_setup.h" // levelfadecol #include "../p_setup.h" // levelfadecol
#include "../p_world.h"
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// This is global data for planes rendering // This is global data for planes rendering
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
extrasubsector_t *extrasubsectors = NULL;
// newsubsectors are subsectors without segs, added for the plane polygons // newsubsectors are subsectors without segs, added for the plane polygons
#define NEWSUBSECTORS 50 #define NEWSUBSECTORS 50
static size_t totsubsectors; static size_t totsubsectors;
size_t addsubsector;
typedef struct typedef struct
{ {
...@@ -45,121 +43,24 @@ typedef struct ...@@ -45,121 +43,24 @@ typedef struct
// FLOOR & CEILING CONVEX POLYS GENERATION // FLOOR & CEILING CONVEX POLYS GENERATION
// ========================================================================== // ==========================================================================
//debug counters
static INT32 nobackpoly = 0;
static INT32 skipcut = 0;
static INT32 totalsubsecpolys = 0;
// --------------------------------------------------------------------------
// Polygon fast alloc / free
// --------------------------------------------------------------------------
//hurdler: quick fix for those who wants to play with larger wad
#define ZPLANALLOC
#ifndef ZPLANALLOC
//#define POLYPOOLSIZE 1024000 // may be much over what is needed
/// \todo check out how much is used
static size_t POLYPOOLSIZE = 1024000;
static UINT8 *gl_polypool = NULL;
static UINT8 *gl_ppcurrent;
static size_t gl_ppfree;
#endif
// only between levels, clear poly pool
static void HWR_ClearPolys(void)
{
#ifndef ZPLANALLOC
gl_ppcurrent = gl_polypool;
gl_ppfree = POLYPOOLSIZE;
#endif
}
// allocate pool for fast alloc of polys
void HWR_InitPolyPool(void)
{
#ifndef ZPLANALLOC
INT32 pnum;
//hurdler: quick fix for those who wants to play with larger wad
if ((pnum = M_CheckParm("-polypoolsize")))
POLYPOOLSIZE = atoi(myargv[pnum+1])*1024; // (in kb)
CONS_Debug(DBG_RENDER, "HWR_InitPolyPool(): allocating %d bytes\n", POLYPOOLSIZE);
gl_polypool = malloc(POLYPOOLSIZE);
if (!gl_polypool)
I_Error("HWR_InitPolyPool(): couldn't malloc polypool\n");
HWR_ClearPolys();
#endif
}
void HWR_FreePolyPool(void)
{
#ifndef ZPLANALLOC
if (gl_polypool)
free(gl_polypool);
gl_polypool = NULL;
#endif
}
static poly_t *HWR_AllocPoly(INT32 numpts) static poly_t *HWR_AllocPoly(INT32 numpts)
{ {
poly_t *p;
size_t size = sizeof (poly_t) + sizeof (polyvertex_t) * numpts; size_t size = sizeof (poly_t) + sizeof (polyvertex_t) * numpts;
#ifdef ZPLANALLOC poly_t *p = Z_Malloc(size, PU_HWRPLANE, NULL);
p = Z_Malloc(size, PU_HWRPLANE, NULL);
#else
#ifdef PARANOIA
if (!gl_polypool)
I_Error("Used gl_polypool without init!\n");
if (!gl_ppcurrent)
I_Error("gl_ppcurrent == NULL!\n");
#endif
if (gl_ppfree < size)
I_Error("HWR_AllocPoly(): no more memory %u bytes left, %u bytes needed\n\n%s\n",
gl_ppfree, size, "You can try the param -polypoolsize 2048 (or higher if needed)");
p = (poly_t *)gl_ppcurrent;
gl_ppcurrent += size;
gl_ppfree -= size;
#endif
p->numpts = numpts; p->numpts = numpts;
return p; return p;
} }
static polyvertex_t *HWR_AllocVertex(void) static polyvertex_t *HWR_AllocVertex(void)
{ {
polyvertex_t *p; return Z_Malloc(sizeof (polyvertex_t), PU_HWRPLANE, NULL);
size_t size = sizeof (polyvertex_t);
#ifdef ZPLANALLOC
p = Z_Malloc(size, PU_HWRPLANE, NULL);
#else
if (gl_ppfree < size)
I_Error("HWR_AllocVertex(): no more memory %u bytes left, %u bytes needed\n\n%s\n",
gl_ppfree, size, "You can try the param -polypoolsize 2048 (or higher if needed)");
p = (polyvertex_t *)gl_ppcurrent;
gl_ppcurrent += size;
gl_ppfree -= size;
#endif
return p;
} }
/// \todo polygons should be freed in reverse order for efficiency,
/// for now don't free because it doesn't free in reverse order
static void HWR_FreePoly(poly_t *poly) static void HWR_FreePoly(poly_t *poly)
{ {
#ifdef ZPLANALLOC
Z_Free(poly); Z_Free(poly);
#else
const size_t size = sizeof (poly_t) + sizeof (polyvertex_t) * poly->numpts;
memset(poly, 0x00, size);
//mempoly -= polysize;
#endif
} }
// Return interception along bsp line, // Return interception along bsp line,
// with the polygon segment // with the polygon segment
// //
...@@ -532,9 +433,6 @@ static poly_t *CutOutSubsecPoly(seg_t *lseg, INT32 count, poly_t *poly) ...@@ -532,9 +433,6 @@ static poly_t *CutOutSubsecPoly(seg_t *lseg, INT32 count, poly_t *poly)
// only when the cut is not needed it seems (when the cut // only when the cut is not needed it seems (when the cut
// line is aligned to one of the borders of the poly, and // line is aligned to one of the borders of the poly, and
// only some times..) // only some times..)
else
skipcut++;
// I_Error("CutOutPoly: only one point for split line (%d %d) %d", ps, pe, debugpos);
} }
} }
return poly; return poly;
...@@ -551,16 +449,15 @@ static inline void HWR_SubsecPoly(INT32 num, poly_t *poly) ...@@ -551,16 +449,15 @@ static inline void HWR_SubsecPoly(INT32 num, poly_t *poly)
subsector_t *sub; subsector_t *sub;
seg_t *lseg; seg_t *lseg;
sub = &subsectors[num]; sub = &world->subsectors[num];
count = sub->numlines; count = sub->numlines;
lseg = &segs[sub->firstline]; lseg = &world->segs[sub->firstline];
if (poly) if (poly)
{ {
poly = CutOutSubsecPoly (lseg,count,poly); poly = CutOutSubsecPoly (lseg,count,poly);
totalsubsecpolys++;
//extra data for this subsector //extra data for this subsector
extrasubsectors[num].planepoly = poly; world->extrasubsectors[num].planepoly = poly;
} }
} }
...@@ -627,13 +524,13 @@ static void WalkBSPNode(INT32 bspnum, poly_t *poly, UINT16 *leafnode, fixed_t *b ...@@ -627,13 +524,13 @@ static void WalkBSPNode(INT32 bspnum, poly_t *poly, UINT16 *leafnode, fixed_t *b
if (poly && poly->numpts > 2) if (poly && poly->numpts > 2)
{ {
CONS_Debug(DBG_RENDER, "Adding a new subsector\n"); CONS_Debug(DBG_RENDER, "Adding a new subsector\n");
if (addsubsector == numsubsectors + NEWSUBSECTORS) if (world->numextrasubsectors == numsubsectors + NEWSUBSECTORS)
I_Error("WalkBSPNode: not enough addsubsectors\n"); I_Error("WalkBSPNode: not enough addsubsectors\n");
else if (addsubsector > 0x7fff) else if (world->numextrasubsectors > 0x7fff)
I_Error("WalkBSPNode: addsubsector > 0x7fff\n"); I_Error("WalkBSPNode: addsubsector > 0x7fff\n");
*leafnode = (UINT16)((UINT16)addsubsector | NF_SUBSECTOR); *leafnode = (UINT16)((UINT16)world->numextrasubsectors | NF_SUBSECTOR);
extrasubsectors[addsubsector].planepoly = poly; world->extrasubsectors[world->numextrasubsectors].planepoly = poly;
addsubsector++; world->numextrasubsectors++;
} }
//add subsectors without segs here? //add subsectors without segs here?
...@@ -653,7 +550,7 @@ static void WalkBSPNode(INT32 bspnum, poly_t *poly, UINT16 *leafnode, fixed_t *b ...@@ -653,7 +550,7 @@ static void WalkBSPNode(INT32 bspnum, poly_t *poly, UINT16 *leafnode, fixed_t *b
#endif #endif
} }
M_ClearBox(bbox); M_ClearBox(bbox);
poly = extrasubsectors[bspnum & ~NF_SUBSECTOR].planepoly; poly = world->extrasubsectors[bspnum & ~NF_SUBSECTOR].planepoly;
for (i = 0, pt = poly->pts; i < poly->numpts; i++,pt++) for (i = 0, pt = poly->pts; i < poly->numpts; i++,pt++)
M_AddToBox(bbox, FLOAT_TO_FIXED(pt->x), FLOAT_TO_FIXED(pt->y)); M_AddToBox(bbox, FLOAT_TO_FIXED(pt->x), FLOAT_TO_FIXED(pt->y));
...@@ -666,10 +563,6 @@ static void WalkBSPNode(INT32 bspnum, poly_t *poly, UINT16 *leafnode, fixed_t *b ...@@ -666,10 +563,6 @@ static void WalkBSPNode(INT32 bspnum, poly_t *poly, UINT16 *leafnode, fixed_t *b
SplitPoly(&fdivline, poly, &frontpoly, &backpoly); SplitPoly(&fdivline, poly, &frontpoly, &backpoly);
poly = NULL; poly = NULL;
//debug
if (!backpoly)
nobackpoly++;
// Recursively divide front space. // Recursively divide front space.
if (frontpoly) if (frontpoly)
{ {
...@@ -696,11 +589,10 @@ static void WalkBSPNode(INT32 bspnum, poly_t *poly, UINT16 *leafnode, fixed_t *b ...@@ -696,11 +589,10 @@ static void WalkBSPNode(INT32 bspnum, poly_t *poly, UINT16 *leafnode, fixed_t *b
} }
// FIXME: use Z_Malloc() STATIC ? // FIXME: use Z_Malloc() STATIC ?
void HWR_FreeExtraSubsectors(void) void HWR_FreeExtraSubsectors(extrasubsector_t *sub)
{ {
if (extrasubsectors) if (sub)
free(extrasubsectors); free(sub);
extrasubsectors = NULL;
} }
#define MAXDIST 1.5f #define MAXDIST 1.5f
...@@ -774,7 +666,7 @@ static void SearchSegInBSP(INT32 bspnum,polyvertex_t *p,poly_t *poly) ...@@ -774,7 +666,7 @@ static void SearchSegInBSP(INT32 bspnum,polyvertex_t *p,poly_t *poly)
if (bspnum != -1) if (bspnum != -1)
{ {
bspnum &= ~NF_SUBSECTOR; bspnum &= ~NF_SUBSECTOR;
q = extrasubsectors[bspnum].planepoly; q = world->extrasubsectors[bspnum].planepoly;
if (poly == q || !q) if (poly == q || !q)
return; return;
for (j = 0; j < q->numpts; j++) for (j = 0; j < q->numpts; j++)
...@@ -795,7 +687,7 @@ static void SearchSegInBSP(INT32 bspnum,polyvertex_t *p,poly_t *poly) ...@@ -795,7 +687,7 @@ static void SearchSegInBSP(INT32 bspnum,polyvertex_t *p,poly_t *poly)
for (n = k+1; n < newpoly->numpts; n++) for (n = k+1; n < newpoly->numpts; n++)
newpoly->pts[n] = q->pts[n-1]; newpoly->pts[n] = q->pts[n-1];
numsplitpoly++; numsplitpoly++;
extrasubsectors[bspnum].planepoly = world->extrasubsectors[bspnum].planepoly =
newpoly; newpoly;
HWR_FreePoly(q); HWR_FreePoly(q);
return; return;
...@@ -840,9 +732,9 @@ static INT32 SolveTProblem(void) ...@@ -840,9 +732,9 @@ static INT32 SolveTProblem(void)
numsplitpoly = 0; numsplitpoly = 0;
for (l = 0; l < addsubsector; l++) for (l = 0; l < world->numextrasubsectors; l++)
{ {
p = extrasubsectors[l].planepoly; p = world->extrasubsectors[l].planepoly;
if (p) if (p)
for (i = 0; i < p->numpts; i++) for (i = 0; i < p->numpts; i++)
SearchSegInBSP((INT32)numnodes-1, &p->pts[i], p); SearchSegInBSP((INT32)numnodes-1, &p->pts[i], p);
...@@ -870,9 +762,9 @@ static void AdjustSegs(void) ...@@ -870,9 +762,9 @@ static void AdjustSegs(void)
for (i = 0; i < numsubsectors; i++) for (i = 0; i < numsubsectors; i++)
{ {
count = subsectors[i].numlines; count = world->subsectors[i].numlines;
lseg = &segs[subsectors[i].firstline]; lseg = &world->segs[world->subsectors[i].firstline];
p = extrasubsectors[i].planepoly; p = world->extrasubsectors[i].planepoly;
//if (!p) //if (!p)
//continue; //continue;
for (; count--; lseg++) for (; count--; lseg++)
...@@ -955,40 +847,28 @@ void HWR_CreatePlanePolygons(INT32 bspnum) ...@@ -955,40 +847,28 @@ void HWR_CreatePlanePolygons(INT32 bspnum)
{ {
poly_t *rootp; poly_t *rootp;
polyvertex_t *rootpv; polyvertex_t *rootpv;
size_t i;
fixed_t rootbbox[4]; fixed_t rootbbox[4];
CONS_Debug(DBG_RENDER, "Creating polygons, please wait...\n"); CONS_Debug(DBG_RENDER, "Creating polygons, please wait...\n");
#ifdef HWR_LOADING_SCREEN #ifdef HWR_LOADING_SCREEN
ls_count = ls_percent = 0; // reset the loading status ls_count = ls_percent = 0; // reset the loading status
CON_Drawer(); //let the user know what we are doing CON_Drawer(); //let the user know what we are doing
I_FinishUpdate(); // page flip or blit buffer I_FinishUpdate(); // page flip or blit buffer
#endif #endif
HWR_ClearPolys();
// find min/max boundaries of map // find min/max boundaries of map
//CONS_Debug(DBG_RENDER, "Looking for boundaries of map...\n");
M_ClearBox(rootbbox); M_ClearBox(rootbbox);
for (i = 0;i < numvertexes; i++) for (size_t i = 0; i < world->numvertexes; i++)
M_AddToBox(rootbbox, vertexes[i].x, vertexes[i].y); M_AddToBox(rootbbox, world->vertexes[i].x, world->vertexes[i].y);
//CONS_Debug(DBG_RENDER, "Generating subsector polygons... %d subsectors\n", numsubsectors);
HWR_FreeExtraSubsectors();
// allocate extra data for each subsector present in map // allocate extra data for each subsector present in map
totsubsectors = numsubsectors + NEWSUBSECTORS; totsubsectors = world->numsubsectors + NEWSUBSECTORS;
extrasubsectors = calloc(totsubsectors, sizeof (*extrasubsectors)); world->extrasubsectors = calloc(totsubsectors, sizeof (*world->extrasubsectors));
if (extrasubsectors == NULL) if (world->extrasubsectors == NULL)
I_Error("couldn't malloc extrasubsectors totsubsectors %s\n", sizeu1(totsubsectors)); I_Error("couldn't malloc extrasubsectors totsubsectors %s\n", sizeu1(totsubsectors));
// allocate table for back to front drawing of subsectors world->numextrasubsectors = world->numsubsectors; // number of the first new subsector that might be added
/*gl_drawsubsectors = (INT16 *)malloc(sizeof (*gl_drawsubsectors) * totsubsectors);
if (!gl_drawsubsectors)
I_Error("couldn't malloc gl_drawsubsectors\n");*/
// number of the first new subsector that might be added
addsubsector = numsubsectors;
// construct the initial convex poly that encloses the full map // construct the initial convex poly that encloses the full map
rootp = HWR_AllocPoly(4); rootp = HWR_AllocPoly(4);
...@@ -1007,20 +887,10 @@ void HWR_CreatePlanePolygons(INT32 bspnum) ...@@ -1007,20 +887,10 @@ void HWR_CreatePlanePolygons(INT32 bspnum)
rootpv->y = FIXED_TO_FLOAT(rootbbox[BOXBOTTOM]); //ll rootpv->y = FIXED_TO_FLOAT(rootbbox[BOXBOTTOM]); //ll
rootpv++; rootpv++;
WalkBSPNode(bspnum, rootp, NULL,rootbbox); WalkBSPNode(bspnum, rootp, NULL, rootbbox);
i = SolveTProblem(); SolveTProblem();
//CONS_Debug(DBG_RENDER, "%d point divides a polygon line\n",i);
AdjustSegs(); AdjustSegs();
//debug debug..
//if (nobackpoly)
// CONS_Debug(DBG_RENDER, "no back polygon %u times\n",nobackpoly);
//"(should happen only with the deep water trick)"
//if (skipcut)
// CONS_Debug(DBG_RENDER, "%u cuts were skipped because of only one point\n",skipcut);
//CONS_Debug(DBG_RENDER, "done: %u total subsector convex polygons\n", totalsubsecpolys);
} }
#endif //HWRENDER #endif //HWRENDER
...@@ -28,35 +28,6 @@ ...@@ -28,35 +28,6 @@
// structures // structures
// ----------- // -----------
// a vertex of a Doom 'plane' polygon
typedef struct
{
float x;
float y;
float z;
} polyvertex_t;
#ifdef _MSC_VER
#pragma warning(disable : 4200)
#endif
// a convex 'plane' polygon, clockwise order
typedef struct
{
INT32 numpts;
polyvertex_t pts[0];
} poly_t;
#ifdef _MSC_VER
#pragma warning(default : 4200)
#endif
// holds extra info for 3D render, for each subsector in subsectors[]
typedef struct
{
poly_t *planepoly; // the generated convex polygon
} extrasubsector_t;
// needed for sprite rendering // needed for sprite rendering
// equivalent of the software renderer's vissprites // equivalent of the software renderer's vissprites
typedef struct gl_vissprite_s typedef struct gl_vissprite_s
...@@ -97,13 +68,7 @@ typedef struct gl_vissprite_s ...@@ -97,13 +68,7 @@ typedef struct gl_vissprite_s
// -------- // --------
// hw_bsp.c // hw_bsp.c
// -------- // --------
extern extrasubsector_t *extrasubsectors; void HWR_FreeExtraSubsectors(extrasubsector_t *sub);
extern size_t addsubsector;
void HWR_InitPolyPool(void);
void HWR_FreePolyPool(void);
void HWR_FreeExtraSubsectors(void);
// -------- // --------
// hw_cache.c // hw_cache.c
......
This diff is collapsed.
...@@ -33,11 +33,9 @@ void HWR_DrawConsoleBack(UINT32 color, INT32 height); ...@@ -33,11 +33,9 @@ void HWR_DrawConsoleBack(UINT32 color, INT32 height);
void HWR_DrawTutorialBack(UINT32 color, INT32 boxheight); void HWR_DrawTutorialBack(UINT32 color, INT32 boxheight);
void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player); void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player);
void HWR_RenderPlayerView(INT32 viewnumber, player_t *player); void HWR_RenderPlayerView(INT32 viewnumber, player_t *player);
void HWR_ClearSkyDome(void); void HWR_FreeSkyDome(void *skydome);
void HWR_BuildSkyDome(void);
void HWR_DrawViewBorder(INT32 clearlines); void HWR_DrawViewBorder(INT32 clearlines);
void HWR_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum); void HWR_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum);
void HWR_InitTextureMapping(void);
void HWR_SetViewSize(void); void HWR_SetViewSize(void);
void HWR_DrawPatch(patch_t *gpatch, INT32 x, INT32 y, INT32 option); void HWR_DrawPatch(patch_t *gpatch, INT32 x, INT32 y, INT32 option);
void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap); void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap);
......
...@@ -2404,7 +2404,7 @@ static int lib_pSwitchWeather(lua_State *L) ...@@ -2404,7 +2404,7 @@ static int lib_pSwitchWeather(lua_State *L)
if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) // if a player, setup weather for only the player, otherwise setup weather for all players if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) // if a player, setup weather for only the player, otherwise setup weather for all players
user = *((player_t **)luaL_checkudata(L, 2, META_PLAYER)); user = *((player_t **)luaL_checkudata(L, 2, META_PLAYER));
if (!user) // global if (!user) // global
globalweather = weathernum; world->weather = weathernum;
if (!user || P_IsLocalPlayer(user)) if (!user || P_IsLocalPlayer(user))
P_SwitchWeather(weathernum); P_SwitchWeather(weathernum);
return 0; return 0;
...@@ -2520,7 +2520,7 @@ static int lib_pSetSkyboxMobj(lua_State *L) ...@@ -2520,7 +2520,7 @@ static int lib_pSetSkyboxMobj(lua_State *L)
return luaL_error(L, "skybox mobj index %d is out of range for P_SetSkyboxMobj argument #2 (expected 0 or 1)", w); return luaL_error(L, "skybox mobj index %d is out of range for P_SetSkyboxMobj argument #2 (expected 0 or 1)", w);
if (!user || P_IsLocalPlayer(user)) if (!user || P_IsLocalPlayer(user))
skyboxmo[w] = mo; world->skyboxmo[w] = mo;
return 0; return 0;
} }
...@@ -2577,15 +2577,15 @@ static int lib_pStartQuake(lua_State *L) ...@@ -2577,15 +2577,15 @@ static int lib_pStartQuake(lua_State *L)
q_epicenter.z = 0; q_epicenter.z = 0;
lua_pop(L, 1); lua_pop(L, 1);
quake.epicenter = &q_epicenter; world->quake.epicenter = &q_epicenter;
} }
else else
quake.epicenter = NULL; world->quake.epicenter = NULL;
quake.radius = luaL_optinteger(L, 4, 512*FRACUNIT); world->quake.radius = luaL_optinteger(L, 4, 512*FRACUNIT);
// These things are actually used in 2.1. // These things are actually used in 2.1.
quake.intensity = q_intensity; world->quake.intensity = q_intensity;
quake.time = q_time; world->quake.time = q_time;
return 0; return 0;
} }
......