Merge branch 'next' into gametype-clownery

This commit is contained in:
Alam Ed Arias 2019-12-26 14:48:04 -05:00
commit 61a0197339
4 changed files with 72 additions and 54 deletions

View File

@ -661,14 +661,16 @@ UINT8 LUAh_ShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32
LUA_PushUserdata(gL, inflictor, META_MOBJ);
LUA_PushUserdata(gL, source, META_MOBJ);
lua_pushinteger(gL, damage);
lua_pushinteger(gL, damagetype);
}
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
lua_pushvalue(gL, -5);
lua_pushvalue(gL, -5);
lua_pushvalue(gL, -5);
lua_pushvalue(gL, -5);
if (lua_pcall(gL, 4, 1, 0)) {
lua_pushvalue(gL, -6);
lua_pushvalue(gL, -6);
lua_pushvalue(gL, -6);
lua_pushvalue(gL, -6);
lua_pushvalue(gL, -6);
if (lua_pcall(gL, 5, 1, 0)) {
if (!hookp->error || cv_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
@ -749,14 +751,16 @@ boolean LUAh_MobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32
LUA_PushUserdata(gL, inflictor, META_MOBJ);
LUA_PushUserdata(gL, source, META_MOBJ);
lua_pushinteger(gL, damage);
lua_pushinteger(gL, damagetype);
}
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
lua_pushvalue(gL, -5);
lua_pushvalue(gL, -5);
lua_pushvalue(gL, -5);
lua_pushvalue(gL, -5);
if (lua_pcall(gL, 4, 1, 0)) {
lua_pushvalue(gL, -6);
lua_pushvalue(gL, -6);
lua_pushvalue(gL, -6);
lua_pushvalue(gL, -6);
lua_pushvalue(gL, -6);
if (lua_pcall(gL, 5, 1, 0)) {
if (!hookp->error || cv_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);
@ -827,13 +831,15 @@ boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8
LUA_PushUserdata(gL, target, META_MOBJ);
LUA_PushUserdata(gL, inflictor, META_MOBJ);
LUA_PushUserdata(gL, source, META_MOBJ);
lua_pushinteger(gL, damagetype);
}
lua_pushfstring(gL, FMT_HOOKID, hookp->id);
lua_gettable(gL, LUA_REGISTRYINDEX);
lua_pushvalue(gL, -4);
lua_pushvalue(gL, -4);
lua_pushvalue(gL, -4);
if (lua_pcall(gL, 3, 1, 0)) {
lua_pushvalue(gL, -5);
lua_pushvalue(gL, -5);
lua_pushvalue(gL, -5);
lua_pushvalue(gL, -5);
if (lua_pcall(gL, 4, 1, 0)) {
if (!hookp->error || cv_debug & DBG_LUA)
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1));
lua_pop(gL, 1);

View File

@ -1779,7 +1779,7 @@ char *M_GetToken(const char *inputString)
|| stringToUse[startPos] == '\r'
|| stringToUse[startPos] == '\n'
|| stringToUse[startPos] == '\0'
|| stringToUse[startPos] == '"' // we're treating this as whitespace because SLADE likes adding it for no good reason
|| stringToUse[startPos] == '=' || stringToUse[startPos] == ';' // UDMF TEXTMAP.
|| inComment != 0)
&& startPos < stringLength)
{
@ -1837,6 +1837,23 @@ char *M_GetToken(const char *inputString)
texturesToken[1] = '\0';
return texturesToken;
}
// Return entire string within quotes, except without the quotes.
else if (stringToUse[startPos] == '"')
{
endPos = ++startPos;
while (stringToUse[endPos] != '"' && endPos < stringLength)
endPos++;
texturesTokenLength = endPos++ - startPos;
// Assign the memory. Don't forget an extra byte for the end of the string!
texturesToken = (char *)Z_Malloc((texturesTokenLength+1)*sizeof(char),PU_STATIC,NULL);
// Copy the string.
M_Memcpy(texturesToken, stringToUse+startPos, (size_t)texturesTokenLength);
// Make the final character NUL.
texturesToken[texturesTokenLength] = '\0';
return texturesToken;
}
// Now find the end of the token. This includes several additional characters that are okay to capture as one character, but not trailing at the end of another token.
endPos = startPos + 1;
@ -1847,7 +1864,7 @@ char *M_GetToken(const char *inputString)
&& stringToUse[endPos] != ','
&& stringToUse[endPos] != '{'
&& stringToUse[endPos] != '}'
&& stringToUse[endPos] != '"' // see above
&& stringToUse[endPos] != '=' && stringToUse[endPos] != ';' // UDMF TEXTMAP.
&& inComment == 0)
&& endPos < stringLength)
{

View File

@ -13008,7 +13008,7 @@ static void P_SetObjectSpecial(mobj_t *mobj)
}
}
mobj_t *P_SpawnMobjFromMapThing(mapthing_t *mthing, fixed_t x, fixed_t y, fixed_t z, mobjtype_t i)
static mobj_t *P_SpawnMobjFromMapThing(mapthing_t *mthing, fixed_t x, fixed_t y, fixed_t z, mobjtype_t i)
{
mobj_t *mobj = NULL;
boolean doangle = true;
@ -13375,7 +13375,7 @@ void P_SpawnItemPattern(mapthing_t *mthing, boolean bonustime)
{
INT32 numitems = (mthing->type & 1) ? 16 : 8;
fixed_t size = (mthing->type & 1) ? 192*FRACUNIT : 96*FRACUNIT;
mobjtype_t itemtypes[1] = { (mthing->type & 1) ? MT_RING : MT_BLUESPHERE };
mobjtype_t itemtypes[1] = { (mthing->type < 606) ? MT_RING : MT_BLUESPHERE };
P_SpawnItemCircle(mthing, itemtypes, 1, numitems, size, bonustime);
return;
}

View File

@ -488,6 +488,7 @@ static inline void P_LoadRawSubsectors(void *data)
size_t numlevelflats;
levelflat_t *levelflats;
levelflat_t *foundflats;
//SoM: Other files want this info.
size_t P_PrecacheLevelFlats(void)
@ -651,17 +652,8 @@ static void P_LoadRawSectors(UINT8 *data)
{
mapsector_t *ms = (mapsector_t *)data;
sector_t *ss = sectors;
levelflat_t *foundflats;
size_t i;
// Allocate a big chunk of memory as big as our MAXLEVELFLATS limit.
//Fab : FIXME: allocate for whatever number of flats - 512 different flats per level should be plenty
foundflats = calloc(MAXLEVELFLATS, sizeof (*foundflats));
if (foundflats == NULL)
I_Error("Ran out of memory while loading sectors\n");
numlevelflats = 0;
// For each counted sector, copy the sector raw data from our cache pointer ms, to the global table pointer ss.
for (i = 0; i < numsectors; i++, ss++, ms++)
{
@ -728,16 +720,6 @@ static void P_LoadRawSectors(UINT8 *data)
ss->lineoutLength = -1.0l;
#endif // ----- end special tricks -----
}
// set the sky flat num
skyflatnum = P_AddLevelFlat(SKYFLATNAME, foundflats);
// copy table for global usage
levelflats = M_Memcpy(Z_Calloc(numlevelflats * sizeof (*levelflats), PU_LEVEL, NULL), foundflats, numlevelflats * sizeof (levelflat_t));
free(foundflats);
// search for animated flats and set up
P_SetupLevelFlatAnims();
}
//
@ -1449,7 +1431,6 @@ static void P_LoadRawSideDefs2(void *data)
break;
}
}
R_ClearTextureNumCache(true);
}
static boolean LineInBlock(fixed_t cx1, fixed_t cy1, fixed_t cx2, fixed_t cy2, fixed_t bx1, fixed_t by1)
@ -1987,6 +1968,14 @@ static void P_LoadMapData(const virtres_t* virt)
lines = Z_Calloc(numlines * sizeof (*lines), PU_LEVEL, NULL);
mapthings = Z_Calloc(nummapthings * sizeof (*mapthings), PU_LEVEL, NULL);
// Allocate a big chunk of memory as big as our MAXLEVELFLATS limit.
//Fab : FIXME: allocate for whatever number of flats - 512 different flats per level should be plenty
foundflats = calloc(MAXLEVELFLATS, sizeof (*foundflats));
if (foundflats == NULL)
I_Error("Ran out of memory while loading sectors\n");
numlevelflats = 0;
#ifdef UDMF
if (textmap)
{
@ -2001,7 +1990,29 @@ static void P_LoadMapData(const virtres_t* virt)
P_LoadRawLineDefs(virtlinedefs->data);
P_SetupLines();
P_LoadRawSideDefs2(virtsidedefs->data);
P_PrepareRawThings(virtthings->data);
}
R_ClearTextureNumCache(true);
// set the sky flat num
skyflatnum = P_AddLevelFlat(SKYFLATNAME, foundflats);
// copy table for global usage
levelflats = M_Memcpy(Z_Calloc(numlevelflats * sizeof (*levelflats), PU_LEVEL, NULL), foundflats, numlevelflats * sizeof (levelflat_t));
free(foundflats);
// search for animated flats and set up
P_SetupLevelFlatAnims();
// Copy relevant map data for NetArchive purposes.
spawnsectors = Z_Calloc(numsectors * sizeof (*sectors), PU_LEVEL, NULL);
spawnlines = Z_Calloc(numlines * sizeof (*lines), PU_LEVEL, NULL);
spawnsides = Z_Calloc(numsides * sizeof (*sides), PU_LEVEL, NULL);
memcpy(spawnsectors, sectors, numsectors * sizeof (*sectors));
memcpy(spawnlines, lines, numlines * sizeof (*lines));
memcpy(spawnsides, sides, numsides * sizeof (*sides));
}
#if 0
@ -2179,8 +2190,6 @@ void P_LoadThingsOnly(void)
// Search through all the thinkers.
thinker_t *think;
INT32 i, viewid = -1, centerid = -1; // for skyboxes
virtres_t* virt = vres_GetMap(lastloadedmaplumpnum);
virtlump_t* vth = vres_Find(virt, "THINGS");
// check if these are any of the normal viewpoint/centerpoint mobjs in the level or not
if (skyboxmo[0] || skyboxmo[1])
@ -2201,11 +2210,8 @@ void P_LoadThingsOnly(void)
P_LevelInitStuff();
P_PrepareRawThings(vth->data);
P_LoadThings(true);
vres_Free(virt);
// restore skybox viewpoint/centerpoint if necessary, set them to defaults if we can't do that
skyboxmo[0] = skyboxviewpnts[(viewid >= 0) ? viewid : 0];
skyboxmo[1] = skyboxcenterpnts[(centerid >= 0) ? centerid : 0];
@ -2767,17 +2773,6 @@ boolean P_SetupLevel(boolean skipprecip)
P_LoadLineDefs2();
P_GroupLines();
// Copy relevant map data for NetArchive purposes.
spawnsectors = Z_Calloc(numsectors * sizeof (*sectors), PU_LEVEL, NULL);
spawnlines = Z_Calloc(numlines * sizeof (*lines), PU_LEVEL, NULL);
spawnsides = Z_Calloc(numsides * sizeof (*sides), PU_LEVEL, NULL);
memcpy(spawnsectors, sectors, numsectors * sizeof (*sectors));
memcpy(spawnlines, lines, numlines * sizeof (*lines));
memcpy(spawnsides, sides, numsides * sizeof (*sides));
P_PrepareRawThings(vres_Find(virt, "THINGS")->data);
P_MakeMapMD5(virt, &mapmd5);
vres_Free(virt);