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
Select Git revision

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
  • 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
  • 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
  • Jisk/srb-2-beef-jerky
117 results
Select Git revision
Show changes
Commits on Source (1)
......@@ -640,10 +640,37 @@ linedeftypes
prefix = "(63)";
}
540
{
title = "Floor Friction";
prefix = "(540)";
}
}
tagging
{
title = "Tagging";
94
{
title = "Flood Sectors With Tag";
prefix = "(94)";
flags8192text = "[13] Use front side offsets";
flags32768text = "[15] Use back side offsets";
}
95
{
title = "Flood Sectors Blocker";
prefix = "(95)";
}
96
{
title = "Apply Tag to Tagged Sectors";
title = "Apply Tag to Other Sectors";
prefix = "(96)";
flags256text = "[8] Targets are sector indices";
flags512text = "[9] Don't apply tag from sector";
flags1024text = "[10] Offsets are target tags";
flags8192text = "[13] Use front side offsets";
flags32768text = "[15] Use back side offsets";
......@@ -672,11 +699,142 @@ linedeftypes
flags8192text = "[13] Use front side offsets";
flags32768text = "[15] Use back side offsets";
}
}
540
macros
{
title = "Macros";
70
{
title = "Floor Friction";
prefix = "(540)";
title = "Expand Macro - First Line";
prefix = "(70)";
}
71
{
title = "Expand Macro - Continued";
prefix = "(71)";
}
72
{
title = "Define Macro";
prefix = "(72)";
}
73
{
title = "Macro Parameters - Linedef";
prefix = "(73)";
}
74
{
title = "Macro Parameters - Sidedef";
prefix = "(74)";
flags8192text = "[13] Back sidedef";
}
75
{
title = "Macro Parameters - Sector";
prefix = "(75)";
flags8192text = "[13] Back sector";
flags16384text = "[14] Unify specials";
}
76
{
title = "Macro Parameters - Vertex";
prefix = "(76)";
}
77
{
title = "Macro Parameters - Thing";
prefix = "(77)";
}
78
{
title = "Macro Variables - New Tags";
prefix = "(78)";
}
79
{
title = "Macro Variables - Calculation";
prefix = "(79)";
flags8192text = "[13] Single calculation";
}
80
{
title = "Macro Proxy - Linedef";
prefix = "(80)";
flags8text = "[3] Set special";
flags16text = "[4] Set tag";
flags32text = "[5] Change flags";
flags256text = "[8] Set first sidedef";
flags512text = "[9] Set second sidedef";
flags1024text = "[10] Set first vertex";
flags2048text = "[11] Set second vertex";
flags32768text = "[15] Target linedef by index";
}
81
{
title = "Macro Proxy - Sidedef";
prefix = "(81)";
flags8text = "[3] Set X offset";
flags16text = "[4] Set Y offset";
flags32text = "[5] Set upper texture";
flags64text = "[6] Set middle texture";
flags128text = "[7] Set lower texture";
flags256text = "[8] Set sector index";
flags8192text = "[13] Back sidedef";
flags32768text = "[15] Target sidedef by index";
}
82
{
title = "Macro Proxy - Sector";
prefix = "(82)";
flags8text = "[3] Set floor height";
flags16text = "[4] Set ceiling height";
flags32text = "[5] Set floor flat";
flags64text = "[6] Set ceiling flat";
flags128text = "[7] Set special (group 1)";
flags256text = "[8] Set light level";
flags512text = "[9] Set tag";
flags1024text = "[10] Set special group 2";
flags2048text = "[11] Set special group 3";
flags4096text = "[12] Set special group 4";
flags8192text = "[13] Back sector";
flags16384text = "[14] Unify specials";
flags32768text = "[15] Target sector by index";
}
83
{
title = "Macro Proxy - Vertex";
prefix = "(83)";
flags8text = "[3] Change X position";
flags16text = "[4] Change Y position";
flags2048text = "[11] First vertex";
flags4096text = "[12] Second vertex";
flags8192text = "[13] Absolute X position";
flags16384text = "[14] Absolute Y position";
flags32768text = "[15] Target vertex by index";
}
84
{
title = "Macro Proxy - Thing";
prefix = "(84)";
flags8text = "[3] Change X position";
flags16text = "[4] Change Y position";
flags32text = "[5] Change flags";
flags64text = "[6] Copy thing";
flags128text = "[7] New thing";
flags256text = "[8] Set angle";
flags512text = "[9] Set Z position";
flags1024text = "[10] Set parameter";
flags2048text = "[11] Set type";
flags8192text = "[13] Absolute X position";
flags16384text = "[14] Absolute Y position";
flags32768text = "[15] Target thing by index";
}
}
......@@ -4822,6 +4980,14 @@ thingtypes
title = "Object Angle Anchor";
sprite = "internal:view";
}
759
{
title = "Macro Thing Helper";
angletext = "Tag";
fixedrotation = 1;
}
760
{
title = "PolyObject Anchor";
......
......@@ -43,6 +43,7 @@ p_map.c
p_maputl.c
p_mobj.c
p_polyobj.c
p_preprocess.c
p_saveg.c
p_setup.c
p_sight.c
......
......@@ -63,15 +63,11 @@ enum
// Do not use bit five or after, as they are used for object z-offsets.
#if defined(_MSC_VER)
#pragma pack(1)
#endif
// A single Vertex.
typedef struct
{
INT16 x, y;
}ATTRPACK mapvertex_t;
} ATTRPACK mapvertex_t;
// A SideDef, defining the visual appearance of a wall,
// by setting textures and offsets.
......@@ -80,15 +76,15 @@ typedef struct
INT16 textureoffset, rowoffset;
char toptexture[8], bottomtexture[8], midtexture[8];
// Front sector, towards viewer.
INT16 sector;
UINT16 sector;
} ATTRPACK mapsidedef_t;
// A LineDef, as used for editing, and as input
// to the BSP builder.
typedef struct
{
INT16 v1, v2;
INT16 flags;
UINT16 v1, v2;
UINT16 flags;
INT16 special;
INT16 tag;
// sidenum[1] will be 0xffff if one sided
......@@ -154,6 +150,16 @@ typedef struct
INT16 tag;
} ATTRPACK mapsector_t;
// Actual thing structure found in binary maps; `mapthing_t` has been
// contaminated with other stuff.
typedef struct
{
INT16 x, y;
INT16 angle;
UINT16 type;
UINT16 options;
} ATTRPACK raw_mapthing_t;
// SubSector, as generated by BSP.
typedef struct
{
......@@ -181,7 +187,7 @@ typedef struct
typedef struct
{
// Partition line from (x,y) to x+dx,y+dy)
// Partition line from (x,y) to (x+dx,y+dy)
INT16 x, y;
INT16 dx, dy;
......@@ -192,10 +198,6 @@ typedef struct
UINT16 children[2];
} ATTRPACK mapnode_t;
#if defined(_MSC_VER)
#pragma pack()
#endif
#define NUMMAPTHINGARGS 6
#define NUMMAPTHINGSTRINGARGS 2
......@@ -217,6 +219,8 @@ typedef struct
} mapthing_t;
#define ZSHIFT 4
#define PARAMSHIFT 12
#define TYPEMASK 0xFFF
#define NUMMAPS 1035
......
......@@ -692,11 +692,20 @@ void LUA_DumpFile(const char *filename)
}
#endif
fixed_t LUA_EvalMath(const char *word)
fixed_t LUA_EvalMathEx(const char *math, boolean soc, boolean is_expr,
lua_eval_math_callback_t setter, lua_eval_math_callback_t getter,
void *callback_data)
{
lua_State *L = NULL;
char buf[1024], *b;
const char *p;
size_t math_idx = 0;
size_t math_len = strlen(math);
// Make sure there's space for "return " and the null terminator, so add 8.
size_t buf_size = math_len + 8;
char *buf = Z_Malloc(buf_size, PU_LUA, NULL);
size_t buf_idx = 0;
fixed_t res = 0;
// make a new state so SOC can't interefere with scripts
......@@ -709,34 +718,55 @@ fixed_t LUA_EvalMath(const char *word)
lua_pushboolean(L, true);
lua_call(L, 1, 0);
// change ^ into ^^ for Lua.
strcpy(buf, "return ");
b = buf+strlen(buf);
for (p = word; *p && b < &buf[1022]; p++)
{
*b++ = *p;
if (*p == '^')
*b++ = '^';
// If it exists, call the callback so it can add variables.
if (setter != NULL)
setter(L, callback_data);
if (is_expr) {
strcpy(buf, "return ");
buf_idx += 7;
buf_size += 7;
}
*b = '\0';
// Copy characters over, adjusting for SOC if necessary.
for (; math_idx < math_len; math_idx++, buf_idx++) {
char c = math[math_idx];
buf[buf_idx] = c;
if (soc && c == '^') {
buf = Z_Realloc(buf, ++buf_size, PU_LUA, NULL);
buf[++buf_idx] = '^';
}
}
buf[buf_idx] = '\0';
// eval string.
lua_settop(L, 0);
if (luaL_dostring(L, buf))
{
p = lua_tostring(L, -1);
if (luaL_dostring(L, buf)) {
const char *p = lua_tostring(L, -1);
while (*p++ != ':' && *p) ;
p += 3; // "1: "
CONS_Alert(CONS_WARNING, "%s\n", p);
} else {
if (is_expr)
res = lua_tointeger(L, -1);
// If it exists, call the other callback so it can examine variables.
if (getter != NULL)
getter(L, callback_data);
}
else
res = lua_tointeger(L, -1);
// clean up and return.
lua_close(L);
Z_Free(buf);
return res;
}
fixed_t LUA_EvalMath(const char *math)
{
return LUA_EvalMathEx(math, true, true, NULL, NULL, NULL);
}
// Takes a pointer, any pointer, and a metatable name
// Creates a userdata for that pointer with the given metatable
// Pushes it to the stack and stores it in the registry.
......
......@@ -49,7 +49,11 @@ void LUA_LoadLump(UINT16 wad, UINT16 lump, boolean noresults);
#ifdef LUA_ALLOW_BYTECODE
void LUA_DumpFile(const char *filename);
#endif
fixed_t LUA_EvalMath(const char *word);
typedef void (*lua_eval_math_callback_t)(lua_State *L, void *data);
fixed_t LUA_EvalMathEx(const char *math, boolean soc, boolean is_expr,
lua_eval_math_callback_t setter, lua_eval_math_callback_t getter,
void *callback_data);
fixed_t LUA_EvalMath(const char *math);
void LUA_Step(void);
void LUA_Archive(void);
void LUA_UnArchive(void);
......
This diff is collapsed.
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 2021 by Sonic Team Junior.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/** \file p_preprocess.h
* \brief Runs preprocessing on raw WAD binary maps before they are converted
* to internal data structures.
*/
#ifndef __P_PREPROCESS__
#define __P_PREPROCESS__
#include "doomdata.h"
#include "doomdef.h"
#include "doomtype.h"
#include "r_main.h"
#include "w_wad.h"
/** Pack of all map geometry into one struct that can be passed around easily through
* preprocessing functions. Also contains preprocessing state.
*/
typedef struct
{
size_t num_vertices;
size_t num_sidedefs;
size_t num_linedefs;
size_t num_sectors;
size_t num_things;
mapvertex_t *vertices;
mapsidedef_t *sidedefs;
maplinedef_t *linedefs;
mapsector_t *sectors;
raw_mapthing_t *things;
//! Holds the tag returned by the last `P_GetNewTag` call.
INT16 last_tag;
} mappack_t;
// Creation and deletion functions for map packs.
void P_NewEmptyMapPack(mappack_t *pack);
void P_NewMapPackFromLumps(mappack_t *pack,
virtlump_t *virtvertices,
virtlump_t *virtsidedefs,
virtlump_t *virtlinedefs,
virtlump_t *virtsectors,
virtlump_t *virtthings);
void P_FreeMapPack(mappack_t *pack);
// General functions to add new geometry.
mapvertex_t *P_AppendVertices(mappack_t *pack, size_t new, const mapvertex_t *fill);
mapsidedef_t *P_AppendSidedefs(mappack_t *pack, size_t new, const mapsidedef_t *fill);
maplinedef_t *P_AppendLinedefs(mappack_t *pack, size_t new, const maplinedef_t *fill);
mapsector_t *P_AppendSectors (mappack_t *pack, size_t new, const mapsector_t *fill);
raw_mapthing_t *P_AppendThings (mappack_t *pack, size_t new, const raw_mapthing_t *fill);
// Special map pack functions.
INT16 P_GetNewTag(mappack_t *pack);
// Other utility functions.
int P_HasSharedVertex(maplinedef_t *first, maplinedef_t *second);
angle_t P_GetLinedefAngle(maplinedef_t *linedef, mappack_t *pack);
angle_t P_GetBidiLinedefAngle(maplinedef_t *linedef, mappack_t *pack);
int P_FindNextConnectedLinedef(maplinedef_t **linedef, maplinedef_t **previous,
INT16 special_low, INT16 special_high, mappack_t *pack);
raw_mapthing_t *P_FindThingByTypeAndAngle(INT16 type, INT16 angle, mappack_t *pack);
maplinedef_t *P_GetClosestAngleLinedef(maplinedef_t *linedef, mappack_t *pack);
// Actual preprocessor function that does all the magic.
void P_PreprocessBinaryMapPack(mappack_t *pack);
#endif
......@@ -17,6 +17,7 @@
#include "g_game.h"
#include "p_local.h"
#include "p_preprocess.h"
#include "p_setup.h"
#include "p_spec.h"
#include "p_saveg.h"
......@@ -792,7 +793,7 @@ void P_ScanThings(INT16 mapnum, INT16 wadnum, INT16 lumpnum)
for (i = 0; i < n; i++)
{
data += 3 * sizeof (INT16); // skip x y position, angle
type = READUINT16(data) & 4095;
type = READUINT16(data) & TYPEMASK;
data += sizeof (INT16); // skip options
switch (type)
......@@ -930,7 +931,7 @@ void P_WriteThings(void)
WRITEINT16(savebuf_p, mt->angle);
temp = (INT16)(mt->type + ((INT16)mt->extrainfo << 12));
temp = (INT16)(mt->type + ((INT16)mt->extrainfo << PARAMSHIFT));
WRITEINT16(savebuf_p, temp);
WRITEUINT16(savebuf_p, mt->options);
}
......@@ -948,9 +949,8 @@ void P_WriteThings(void)
// MAP LOADING FUNCTIONS
//
static void P_LoadVertices(UINT8 *data)
static void P_LoadVertices(mapvertex_t *mv)
{
mapvertex_t *mv = (mapvertex_t *)data;
vertex_t *v = vertexes;
size_t i;
......@@ -1019,9 +1019,8 @@ static void P_InitializeSector(sector_t *ss)
ss->spawn_extra_colormap = NULL;
}
static void P_LoadSectors(UINT8 *data)
static void P_LoadSectors(mapsector_t *ms)
{
mapsector_t *ms = (mapsector_t *)data;
sector_t *ss = sectors;
size_t i;
......@@ -1136,9 +1135,8 @@ static void P_SetLinedefV2(size_t i, UINT16 vertex_num)
lines[i].v2 = &vertexes[vertex_num];
}
static void P_LoadLinedefs(UINT8 *data)
static void P_LoadLinedefs(maplinedef_t *mld)
{
maplinedef_t *mld = (maplinedef_t *)data;
line_t *ld = lines;
size_t i;
......@@ -1185,9 +1183,8 @@ static void P_InitializeSidedef(side_t *sd)
sd->colormap_data = NULL;
}
static void P_LoadSidedefs(UINT8 *data)
static void P_LoadSidedefs(mapsidedef_t *msd)
{
mapsidedef_t *msd = (mapsidedef_t*)data;
side_t *sd = sides;
size_t i;
......@@ -1233,28 +1230,17 @@ static void P_LoadSidedefs(UINT8 *data)
case 413: // Change music
{
char process[8+1];
sd->toptexture = sd->midtexture = sd->bottomtexture = 0;
if (msd->bottomtexture[0] != '-' || msd->bottomtexture[1] != '\0')
{
M_Memcpy(process,msd->bottomtexture,8);
process[8] = '\0';
sd->bottomtexture = get_number(process);
}
if (!R_IsBlankTexture(msd->bottomtexture))
sd->bottomtexture = get_number(R_NullTermTexture(msd->bottomtexture));
if (!(msd->midtexture[0] == '-' && msd->midtexture[1] == '\0') || msd->midtexture[1] != '\0')
{
M_Memcpy(process,msd->midtexture,8);
process[8] = '\0';
sd->midtexture = get_number(process);
}
if (!R_IsBlankTexture(msd->midtexture))
sd->midtexture = get_number(R_NullTermTexture(msd->midtexture));
sd->text = Z_Malloc(7, PU_LEVEL, NULL);
if (isfrontside && !(msd->toptexture[0] == '-' && msd->toptexture[1] == '\0'))
if (isfrontside && !R_IsBlankTexture(msd->toptexture))
{
M_Memcpy(process,msd->toptexture,8);
process[8] = '\0';
char *process = R_NullTermTexture(msd->toptexture);
// If they type in O_ or D_ and their music name, just shrug,
// then copy the rest instead.
......@@ -1273,13 +1259,8 @@ static void P_LoadSidedefs(UINT8 *data)
case 414: // Play SFX
{
sd->toptexture = sd->midtexture = sd->bottomtexture = 0;
if (msd->toptexture[0] != '-' || msd->toptexture[1] != '\0')
{
char process[8+1];
M_Memcpy(process,msd->toptexture,8);
process[8] = '\0';
sd->toptexture = get_number(process);
}
if (!R_IsBlankTexture(msd->toptexture))
sd->toptexture = get_number(R_NullTermTexture(msd->toptexture));
break;
}
......@@ -1295,18 +1276,10 @@ static void P_LoadSidedefs(UINT8 *data)
case 461: // Spawns an object on the map based on texture offsets
case 463: // Colorizes an object
{
char process[8*3+1];
memset(process,0,8*3+1);
sd->toptexture = sd->midtexture = sd->bottomtexture = 0;
if (msd->toptexture[0] == '-' && msd->toptexture[1] == '\0')
break;
else
M_Memcpy(process,msd->toptexture,8);
if (msd->midtexture[0] != '-' || msd->midtexture[1] != '\0')
M_Memcpy(process+strlen(process), msd->midtexture, 8);
if (msd->bottomtexture[0] != '-' || msd->bottomtexture[1] != '\0')
M_Memcpy(process+strlen(process), msd->bottomtexture, 8);
char *process = R_CombineTextures(
msd->toptexture, msd->midtexture, msd->bottomtexture);
sd->toptexture = get_number(process);
sd->midtexture = sd->bottomtexture = 0;
break;
}
......@@ -1316,19 +1289,40 @@ static void P_LoadSidedefs(UINT8 *data)
case 443: // Calls a named Lua function
case 459: // Control text prompt (named tag)
{
char process[8*3+1];
memset(process,0,8*3+1);
char *process = R_CombineTextures(
msd->toptexture, msd->midtexture, msd->bottomtexture);
M_Memcpy(sd->text, process, strlen(process) + 1);
sd->toptexture = sd->midtexture = sd->bottomtexture = 0;
break;
}
case 72: // Define Macro
case 73: // Macro Parameters - Linedef
case 74: // Macro Parameters - Sidedef
case 75: // Macro Parameters - Sector
case 76: // Macro Parameters - Vertex
case 77: // Macro Parameters - Thing
case 78: // Macro Variables - New Tags
case 79: // Macro Variables - Calculation
case 80: // Macro Proxy - Linedef
case 81: // Macro Proxy - Sidedef
case 82: // Macro Proxy - Sector
case 83: // Macro Proxy - Vertex
case 84: // Macro Proxy - Thing
// Do nothing; these aren't real textures, and they're already handled in
// the preprocessing stage.
sd->toptexture = sd->midtexture = sd->bottomtexture = 0;
if (msd->toptexture[0] == '-' && msd->toptexture[1] == '\0')
break;
else
M_Memcpy(process,msd->toptexture,8);
if (msd->midtexture[0] != '-' || msd->midtexture[1] != '\0')
M_Memcpy(process+strlen(process), msd->midtexture, 8);
if (msd->bottomtexture[0] != '-' || msd->bottomtexture[1] != '\0')
M_Memcpy(process+strlen(process), msd->bottomtexture, 8);
sd->text = Z_Malloc(strlen(process)+1, PU_LEVEL, NULL);
M_Memcpy(sd->text, process, strlen(process)+1);
break;
case 70: // Expand Macro - First Line
case 71: // Expand Macro - Continued
{
// For these, we can't assume that these are textures (they could be numbers
// or state names or anything, really), so we'll try and load them and do
// nothing if they actually aren't.
sd->midtexture = R_TextureNumForNameEx(msd->midtexture, true);
sd->toptexture = R_TextureNumForNameEx(msd->toptexture, true);
sd->bottomtexture = R_TextureNumForNameEx(msd->bottomtexture, true);
break;
}
......@@ -1365,27 +1359,27 @@ static void P_LoadSidedefs(UINT8 *data)
}
}
static void P_LoadThings(UINT8 *data)
static void P_LoadThings(raw_mapthing_t *bmt)
{
mapthing_t *mt;
size_t i;
for (i = 0, mt = mapthings; i < nummapthings; i++, mt++)
for (i = 0, mt = mapthings; i < nummapthings; i++, mt++, bmt++)
{
mt->x = READINT16(data);
mt->y = READINT16(data);
mt->x = SHORT(bmt->x);
mt->y = SHORT(bmt->y);
mt->angle = READINT16(data);
mt->type = READUINT16(data);
mt->options = READUINT16(data);
mt->extrainfo = (UINT8)(mt->type >> 12);
mt->angle = SHORT(bmt->angle);
mt->type = SHORT(bmt->type);
mt->options = SHORT(bmt->options);
mt->extrainfo = (UINT8)(mt->type >> PARAMSHIFT);
Tag_FSet(&mt->tags, 0);
mt->scale = FRACUNIT;
memset(mt->args, 0, NUMMAPTHINGARGS*sizeof(*mt->args));
memset(mt->stringargs, 0x00, NUMMAPTHINGSTRINGARGS*sizeof(*mt->stringargs));
mt->pitch = mt->roll = 0;
mt->type &= 4095;
mt->type &= TYPEMASK;
if (mt->type == 1705 || (mt->type == 750 && mt->extrainfo))
mt->z = mt->options; // NiGHTS Hoops use the full flags bits to set the height.
......@@ -2086,7 +2080,7 @@ static void P_ProcessLinedefsAfterSidedefs(void)
static boolean P_LoadMapData(const virtres_t *virt)
{
virtlump_t *virtvertexes = NULL, *virtsectors = NULL, *virtsidedefs = NULL, *virtlinedefs = NULL, *virtthings = NULL;
mappack_t pack;
// Count map data.
if (udmf) // Count how many entries for each type we got in textmap.
......@@ -2097,15 +2091,15 @@ static boolean P_LoadMapData(const virtres_t *virt)
}
else
{
virtthings = vres_Find(virt, "THINGS");
virtvertexes = vres_Find(virt, "VERTEXES");
virtsectors = vres_Find(virt, "SECTORS");
virtsidedefs = vres_Find(virt, "SIDEDEFS");
virtlinedefs = vres_Find(virt, "LINEDEFS");
virtlump_t *virtthings = vres_Find(virt, "THINGS");
virtlump_t *virtvertices = vres_Find(virt, "VERTEXES");
virtlump_t *virtsectors = vres_Find(virt, "SECTORS");
virtlump_t *virtsidedefs = vres_Find(virt, "SIDEDEFS");
virtlump_t *virtlinedefs = vres_Find(virt, "LINEDEFS");
if (!virtthings)
I_Error("THINGS lump not found");
if (!virtvertexes)
if (!virtvertices)
I_Error("VERTEXES lump not found");
if (!virtsectors)
I_Error("SECTORS lump not found");
......@@ -2114,12 +2108,18 @@ static boolean P_LoadMapData(const virtres_t *virt)
if (!virtlinedefs)
I_Error("LINEDEFS lump not found");
// Traditional doom map format just assumes the number of elements from the lump sizes.
numvertexes = virtvertexes->size / sizeof (mapvertex_t);
numsectors = virtsectors->size / sizeof (mapsector_t);
numsides = virtsidedefs->size / sizeof (mapsidedef_t);
numlines = virtlinedefs->size / sizeof (maplinedef_t);
nummapthings = virtthings->size / (5 * sizeof (INT16));
P_NewMapPackFromLumps(&pack,
virtvertices, virtsidedefs, virtlinedefs, virtsectors, virtthings);
// Sneak in extra map geometry in the preprocessing stage.
P_PreprocessBinaryMapPack(&pack);
// Now we know our final amount of geometry.
numvertexes = pack.num_vertices;
numsides = pack.num_sidedefs;
numlines = pack.num_linedefs;
numsectors = pack.num_sectors;
nummapthings = pack.num_things;
}
if (numvertexes <= 0)
......@@ -2150,11 +2150,13 @@ static boolean P_LoadMapData(const virtres_t *virt)
P_LoadTextmap();
else
{
P_LoadVertices(virtvertexes->data);
P_LoadSectors(virtsectors->data);
P_LoadLinedefs(virtlinedefs->data);
P_LoadSidedefs(virtsidedefs->data);
P_LoadThings(virtthings->data);
P_LoadVertices(pack.vertices);
P_LoadSectors (pack.sectors);
P_LoadLinedefs(pack.linedefs);
P_LoadSidedefs(pack.sidedefs);
P_LoadThings (pack.things);
P_FreeMapPack(&pack);
}
P_ProcessLinedefsAfterSidedefs();
......@@ -3023,8 +3025,11 @@ static void P_LinkMapData(void)
}
}
// For maps in binary format, add multi-tags from linedef specials. This must be done
// before any linedef specials have been processed.
/** Add tags to either the front or back sector for linedefs 97-99.
*
* \param sector The sector to add the tags to.
* \param line The linedef to add the tags from.
*/
static void P_AddBinaryMapTagsFromLine(sector_t *sector, line_t *line)
{
Tag_Add(&sector->tags, Tag_FGet(&line->tags));
......@@ -3042,6 +3047,9 @@ static void P_AddBinaryMapTagsFromLine(sector_t *sector, line_t *line)
}
}
/** Processes binary map tag specials before any other linedef specials or tag lists
* have been processed, which allows adding tags at will.
*/
static void P_AddBinaryMapTags(void)
{
size_t i;
......
......@@ -17,15 +17,40 @@
#ifndef __P_SPEC__
#define __P_SPEC__
#include "r_defs.h"
extern mobj_t *skyboxmo[2]; // current skybox mobjs: 0 = viewpoint, 1 = centerpoint
extern mobj_t *skyboxviewpnts[16]; // array of MT_SKYBOX viewpoint mobjs
extern mobj_t *skyboxcenterpnts[16]; // array of MT_SKYBOX centerpoint mobjs
// GETSECSPECIAL (specialval, section)
//
// Pulls out the special # from a particular section.
//
#define GETSECSPECIAL(i,j) ((i >> ((j-1)*4))&15)
/** Gets the sector special value from a particular section.
*
* \param special The full sector special value to get the value from.
* \param section The sector special section where the value is located.
* \return The value in the specified sector special section.
*/
static inline INT16 GetSecSpecial(INT16 special, INT16 section)
{
int shift = (section - 1) * 4;
return (special >> shift) & 0xF;
}
// Alias to GetSecSpecial for compatibility.
#define GETSECSPECIAL GetSecSpecial
/** Sets a sector special value in a particular section and returns the modified value.
*
* \param special The full sector special value to modify.
* \param section The sector special section to change.
* \param value The value to put in the sector special section.
* \return The modified special.
*/
static inline INT16 SetSecSpecial(INT16 special, INT16 section, INT16 value)
{
int shift = (section - 1) * 4;
INT16 mask = 0xF << shift;
return (special & ~mask) | ((value << shift) & mask);
}
// This must be updated whenever we up the max flat size - quicker to assume rather than figuring out the sqrt of the specific flat's filesize.
#define MAXFLATSIZE (2048<<FRACBITS)
......
......@@ -17,6 +17,7 @@
#include "d_player.h"
#include "r_data.h"
#include "r_textures.h"
#include "tables.h"
//
// POV related.
......
......@@ -1623,18 +1623,19 @@ INT32 R_CheckTextureNumForName(const char *name)
}
//
// R_TextureNumForName
// R_TextureNumForNameEx
//
// Calls R_CheckTextureNumForName, aborts with error message.
// Calls R_CheckTextureNumForName, can issue a warning on invalid texture.
//
INT32 R_TextureNumForName(const char *name)
INT32 R_TextureNumForNameEx(const char *name, boolean no_warning)
{
const INT32 i = R_CheckTextureNumForName(name);
if (i == -1)
{
static INT32 redwall = -2;
CONS_Debug(DBG_SETUP, "WARNING: R_TextureNumForName: %.8s not found\n", name);
if (!no_warning)
CONS_Debug(DBG_SETUP, "WARNING: R_TextureNumForName: %.8s not found\n", name);
if (redwall == -2)
redwall = R_CheckTextureNumForName("REDWALL");
if (redwall != -1)
......@@ -1643,3 +1644,71 @@ INT32 R_TextureNumForName(const char *name)
}
return i;
}
//
// R_TextureNumForName
//
// Calls R_TextureNumForNameEx and always issues the warning.
//
INT32 R_TextureNumForName(const char *name)
{
return R_TextureNumForNameEx(name, false);
}
/** Returns true if this texture is blank, i.e. it is "-".
*/
boolean R_IsBlankTexture(const char texture[8])
{
return texture[0] == '-' && texture[1] == '\0';
}
/** Returns a temporary buffer that is the same as the passed in texture, but null-
* terminated. For instance, this is necessary for `atoi` to not cause buffer overflows.
* The buffer is static, so only one texture may be used at a time.
*
* \param texture The texture to convert
* \return The null-terminated buffer with the texture.
*/
char *R_NullTermTexture(const char texture[8])
{
static char nulled[9];
memcpy(nulled, texture, 8);
nulled[8] = '\0';
return nulled;
}
/** Returns a temporary null-terminated buffer that is the combination of the passed in
* textures. Null characters from any of the textures are not included, and blank
* textures are ignored. The buffer is static, so only one combined may be used at a time.
*
* \param top The top texture of the sidedef
* \param mid The middle texture of the sidedef
* \param bot The bottom texture of the sidedef.
* \return The buffer with the combined textures.
*/
char *R_CombineTextures(const char top[8], const char mid[8], const char bot[8])
{
static char combined[25];
char *pos = combined;
size_t i;
memset(combined, 0, 25);
if (!R_IsBlankTexture(top)) {
for (i = 0; i < 8 && top[i] != '\0'; i++)
pos[i] = top[i];
pos += i;
}
if (!R_IsBlankTexture(mid)) {
for (i = 0; i < 8 && mid[i] != '\0'; i++)
pos[i] = mid[i];
pos += i;
}
if (!R_IsBlankTexture(bot)) {
for (i = 0; i < 8 && bot[i] != '\0'; i++)
pos[i] = bot[i];
pos += i;
}
return combined;
}
......@@ -95,9 +95,15 @@ void R_CheckFlatLength(size_t size);
// Returns the texture number for the texture name.
INT32 R_TextureNumForName(const char *name);
INT32 R_TextureNumForNameEx(const char *name, boolean no_warning);
INT32 R_CheckTextureNumForName(const char *name);
lumpnum_t R_GetFlatNumForName(const char *name);
// Helper functions for texture strings
boolean R_IsBlankTexture(const char texture[8]);
char *R_NullTermTexture(const char texture[8]);
char *R_CombineTextures(const char top[8], const char mid[8], const char bot[8]);
extern INT32 numtextures;
#endif