- handle all special mapthing items (player starts, polyobj spots) via the new MAPINFO method instead of hard coding them in the spawn function.

(Note: The buildmap loading code should be adjusted to the new functionality as well eventually.)
This commit is contained in:
Christoph Oelckers 2015-04-03 21:17:10 +02:00
parent 15dbbc9137
commit 9e5bf38123
13 changed files with 281 additions and 133 deletions

View file

@ -429,10 +429,10 @@ struct FPlayerStart
short angle, type;
FPlayerStart() { }
FPlayerStart(const FMapThing *mthing)
FPlayerStart(const FMapThing *mthing, int pnum)
: x(mthing->x), y(mthing->y), z(mthing->z),
angle(mthing->angle),
type(mthing->type)
type(pnum)
{ }
};
// Player spawn spots for deathmatch.

View file

@ -43,6 +43,23 @@
#include "v_text.h"
#include "i_system.h"
const char *SpecialMapthingNames[] = {
"$PLAYER1START",
"$PLAYER2START",
"$PLAYER3START",
"$PLAYER4START",
"$PLAYER5START",
"$PLAYER6START",
"$PLAYER7START",
"$PLAYER8START",
"$DEATHMATCHSTART",
"$SSEQOVERRIDE",
"$POLYANCHOR",
"$POLYSPAWN",
"$POLYSPAWNCRUSH",
"$POLYSPAWNHURT"
};
//==========================================================================
//
// Stuff that's only valid during definition time
@ -112,7 +129,7 @@ void FMapInfoParser::ParseDoomEdNums()
editem.filename = sc.ScriptName;
sc.MustGetStringName("{");
ParseOpenBrace();
while (true)
{
if (sc.CheckString("}")) return;
@ -133,7 +150,7 @@ void FMapInfoParser::ParseDoomEdNums()
{
// todo: add special stuff like playerstarts and sound sequence overrides here, too.
editem.classname = NAME_None;
editem.special = 1; // todo: assign proper constants
editem.special = sc.MustMatchString(SpecialMapthingNames) + 1; // todo: assign proper constants
}
else
{
@ -148,7 +165,7 @@ void FMapInfoParser::ParseDoomEdNums()
if (sc.CheckString(","))
{
// todo: parse a special or args
editem.special = 0; // mark args as used - if this is done we need to prevent assignment of map args in P_SpawnMapThing.
if (editem.special < 0) editem.special = 0; // mark args as used - if this is done we need to prevent assignment of map args in P_SpawnMapThing.
if (!sc.CheckNumber())
{
sc.MustGetString();

View file

@ -285,6 +285,25 @@ struct FDoomEdEntry
int Args[5];
};
enum ESpecialMapthings
{
SMT_PLAYER1START = 1,
SMT_PLAYER2START,
SMT_PLAYER3START,
SMT_PLAYER4START,
SMT_PLAYER5START,
SMT_PLAYER6START,
SMT_PLAYER7START,
SMT_PLAYER8START,
SMT_DEATHMATCHSTART,
SMT_SSEQOVERRIDE,
SMT_POLYANCHOR,
SMT_POLYSPAWN,
SMT_POLYSPAWNCRUSH,
SMT_POLYSPAWNHURT,
};
typedef TMap<int, FDoomEdEntry> FDoomEdMap;
extern FDoomEdMap DoomEdMap;

View file

@ -591,19 +591,6 @@ struct polyspawns_t
short type;
};
enum
{
PO_HEX_ANCHOR_TYPE = 3000,
PO_HEX_SPAWN_TYPE,
PO_HEX_SPAWNCRUSH_TYPE,
// [RH] Thing numbers that don't conflict with Doom things
PO_ANCHOR_TYPE = 9300,
PO_SPAWN_TYPE,
PO_SPAWNCRUSH_TYPE,
PO_SPAWNHURT_TYPE
};
extern int po_NumPolyobjs;
extern polyspawns_t *polyspawns; // [RH] list of polyobject things to spawn

View file

@ -4621,68 +4621,59 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position)
return NULL;
}
// count deathmatch start positions
if (mthing->type == 11)
// copy args to mapthing so that we have them in one place for the rest of this function
if (mentry->Special >= 0)
{
FPlayerStart start(mthing);
deathmatchstarts.Push(start);
return NULL;
mthing->special = mentry->Special;
memcpy(mthing->args, mentry->Args, sizeof(mthing->args));
}
// Convert Strife starts to Hexen-style starts
if (gameinfo.gametype == GAME_Strife && mthing->type >= 118 && mthing->type <= 127)
{
mthing->args[0] = mthing->type - 117;
mthing->type = 1;
}
// [RH] Record polyobject-related things
if (gameinfo.gametype == GAME_Hexen)
{
switch (mthing->type)
{
case PO_HEX_ANCHOR_TYPE:
mthing->type = PO_ANCHOR_TYPE;
break;
case PO_HEX_SPAWN_TYPE:
mthing->type = PO_SPAWN_TYPE;
break;
case PO_HEX_SPAWNCRUSH_TYPE:
mthing->type = PO_SPAWNCRUSH_TYPE;
break;
}
}
if (mthing->type == PO_ANCHOR_TYPE ||
mthing->type == PO_SPAWN_TYPE ||
mthing->type == PO_SPAWNCRUSH_TYPE ||
mthing->type == PO_SPAWNHURT_TYPE)
{
polyspawns_t *polyspawn = new polyspawns_t;
polyspawn->next = polyspawns;
polyspawn->x = mthing->x;
polyspawn->y = mthing->y;
polyspawn->angle = mthing->angle;
polyspawn->type = mthing->type;
polyspawns = polyspawn;
if (mthing->type != PO_ANCHOR_TYPE)
po_NumPolyobjs++;
return NULL;
}
// check for players specially
int pnum = -1;
if (mentry->Type == NULL)
{
if (mthing->type <= 4 && mthing->type > 0)
{
pnum = mthing->type - 1;
}
else
{
if (mthing->type >= gameinfo.player5start && mthing->type < gameinfo.player5start + MAXPLAYERS - 4)
switch (mentry->Special)
{
pnum = mthing->type - gameinfo.player5start + 4;
case SMT_DEATHMATCHSTART:
{
// count deathmatch start positions
FPlayerStart start(mthing, 0);
deathmatchstarts.Push(start);
return NULL;
}
case SMT_POLYANCHOR:
case SMT_POLYSPAWN:
case SMT_POLYSPAWNCRUSH:
case SMT_POLYSPAWNHURT:
{
polyspawns_t *polyspawn = new polyspawns_t;
polyspawn->next = polyspawns;
polyspawn->x = mthing->x;
polyspawn->y = mthing->y;
polyspawn->angle = mthing->angle;
polyspawn->type = mentry->Special;
polyspawns = polyspawn;
if (mentry->Special != SMT_POLYANCHOR)
po_NumPolyobjs++;
return NULL;
}
case SMT_PLAYER1START:
case SMT_PLAYER2START:
case SMT_PLAYER3START:
case SMT_PLAYER4START:
case SMT_PLAYER5START:
case SMT_PLAYER6START:
case SMT_PLAYER7START:
case SMT_PLAYER8START:
pnum = mentry->Special - SMT_PLAYER1START;
break;
// Sound sequence override will be handled later
default:
break;
}
}
@ -4750,7 +4741,7 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position)
return NULL;
// save spots for respawning in network games
FPlayerStart start(mthing);
FPlayerStart start(mthing, pnum+1);
playerstarts[pnum] = start;
AllPlayerStarts.Push(start);
if (!deathmatch && !(level.flags2 & LEVEL2_RANDOMPLAYERSTARTS))
@ -4761,20 +4752,10 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position)
}
// [RH] sound sequence overriders
if (mthing->type >= 1400 && mthing->type < 1410)
if (mentry->Type == NULL && mentry->Special == SMT_SSEQOVERRIDE)
{
P_PointInSector (mthing->x, mthing->y)->seqType = mthing->type - 1400;
return NULL;
}
else if (mthing->type == 1411)
{
int type;
if (mthing->args[0] == 255)
type = -1;
else
type = mthing->args[0];
int type = mentry->Args[0];
if (type == 255) type = -1;
if (type > 63)
{
Printf ("Sound sequence %d out of range\n", type);
@ -4786,18 +4767,6 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position)
return NULL;
}
// [RH] Determine if it is an old ambient thing, and if so,
// map it to MT_AMBIENT with the proper parameter.
if (mthing->type >= 14001 && mthing->type <= 14064)
{
mthing->args[0] = mthing->type - 14000;
mthing->type = 14065;
}
else if (mthing->type >= 14101 && mthing->type <= 14164)
{
mthing->args[0] = mthing->type - 14100;
mthing->type = 14165;
}
// [RH] If the thing's corresponding sprite has no frames, also map
// it to the unknown thing.
// Handle decorate replacements explicitly here
@ -4907,7 +4876,7 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position)
}
// if the actor got args defined either in DECORATE or MAPINFO we must ignore the map's properties.
if (!(mobj->flags2 & MF2_ARGSDEFINED) && (mentry == NULL || mentry->Special < 0))
if (!(mobj->flags2 & MF2_ARGSDEFINED))
{
// [RH] Set the thing's special
mobj->special = mthing->special;

View file

@ -3334,32 +3334,16 @@ void P_GetPolySpots (MapData * map, TArray<FNodeBuilder::FPolyStart> &spots, TAr
{
if (map->HasBehavior)
{
int spot1, spot2, spot3, anchor;
if (gameinfo.gametype == GAME_Hexen)
{
spot1 = PO_HEX_SPAWN_TYPE;
spot2 = PO_HEX_SPAWNCRUSH_TYPE;
anchor = PO_HEX_ANCHOR_TYPE;
}
else
{
spot1 = PO_SPAWN_TYPE;
spot2 = PO_SPAWNCRUSH_TYPE;
anchor = PO_ANCHOR_TYPE;
}
spot3 = PO_SPAWNHURT_TYPE;
for (unsigned int i = 0; i < MapThingsConverted.Size(); ++i)
{
if (MapThingsConverted[i].type == spot1 || MapThingsConverted[i].type == spot2 ||
MapThingsConverted[i].type == spot3 || MapThingsConverted[i].type == anchor)
FDoomEdEntry *mentry = DoomEdMap.CheckKey(MapThingsConverted[i].type);
if (mentry != NULL && mentry->Type == NULL && mentry->Special >= SMT_POLYANCHOR && mentry->Special <= SMT_POLYSPAWNHURT)
{
FNodeBuilder::FPolyStart newvert;
newvert.x = MapThingsConverted[i].x;
newvert.y = MapThingsConverted[i].y;
newvert.polynum = MapThingsConverted[i].angle;
if (MapThingsConverted[i].type == anchor)
if (mentry->Special == SMT_POLYANCHOR)
{
anchors.Push (newvert);
}

View file

@ -1561,8 +1561,8 @@ static void SpawnPolyobj (int index, int tag, int type)
sd->linedef->args[0] = 0;
IterFindPolySides(&polyobjs[index], sd);
po->MirrorNum = sd->linedef->args[1];
po->crush = (type != PO_SPAWN_TYPE) ? 3 : 0;
po->bHurtOnTouch = (type == PO_SPAWNHURT_TYPE);
po->crush = (type != SMT_POLYSPAWN) ? 3 : 0;
po->bHurtOnTouch = (type == SMT_POLYSPAWNHURT);
po->tag = tag;
po->seqType = sd->linedef->args[2];
if (po->seqType < 0 || po->seqType > 63)
@ -1632,8 +1632,8 @@ static void SpawnPolyobj (int index, int tag, int type)
}
if (po->Sidedefs.Size() > 0)
{
po->crush = (type != PO_SPAWN_TYPE) ? 3 : 0;
po->bHurtOnTouch = (type == PO_SPAWNHURT_TYPE);
po->crush = (type != SMT_POLYSPAWN) ? 3 : 0;
po->bHurtOnTouch = (type == SMT_POLYSPAWNHURT);
po->tag = tag;
po->seqType = po->Sidedefs[0]->linedef->args[3];
po->MirrorNum = po->Sidedefs[0]->linedef->args[2];
@ -1756,9 +1756,7 @@ void PO_Init (void)
for (polyspawn = polyspawns, prev = &polyspawns; polyspawn;)
{
// 9301 (3001) = no crush, 9302 (3002) = crushing, 9303 = hurting touch
if (polyspawn->type == PO_SPAWN_TYPE ||
polyspawn->type == PO_SPAWNCRUSH_TYPE ||
polyspawn->type == PO_SPAWNHURT_TYPE)
if (polyspawn->type >= SMT_POLYSPAWN && polyspawn->type <= SMT_POLYSPAWNHURT)
{
// Polyobj StartSpot Pt.
polyobjs[polyIndex].StartSpot.x = polyspawn->x;
@ -1778,7 +1776,7 @@ void PO_Init (void)
for (polyspawn = polyspawns; polyspawn;)
{
polyspawns_t *next = polyspawn->next;
if (polyspawn->type == PO_ANCHOR_TYPE)
if (polyspawn->type == SMT_POLYANCHOR)
{
// Polyobj Anchor Pt.
TranslateToStartSpot (polyspawn->angle, polyspawn->x, polyspawn->y);

View file

@ -6,10 +6,26 @@ Gameinfo
DoomEdNums
{
0 = Unknown
14 = TeleportDest
0 = Unknown
1 = "$Player1Start"
2 = "$Player2Start"
3 = "$Player3Start"
4 = "$Player4Start"
11 = "$DeathmatchStart"
14 = TeleportDest
118 = ZBridge
888 = MBFHelperDog
1400 = "$SSeqOverride", 0
1401 = "$SSeqOverride", 1
1402 = "$SSeqOverride", 2
1403 = "$SSeqOverride", 3
1404 = "$SSeqOverride", 4
1405 = "$SSeqOverride", 5
1406 = "$SSeqOverride", 6
1407 = "$SSeqOverride", 7
1408 = "$SSeqOverride", 8
1409 = "$SSeqOverride", 9
1411 = "$SSeqOverride"
5001 = PointPusher
5002 = PointPuller
5004 = FS_Mapspot
@ -53,6 +69,10 @@ DoomEdNums
9082 = SectorSilencer
9083 = SkyCamCompat
9200 = Decal
9300 = "$PolyAnchor"
9301 = "$PolySpawn"
9302 = "$PolySpawnCrush"
9303 = "$PolySpawnHurt"
9982 = SecActEyesAboveC
9983 = SecActEyesBelowC
9988 = CustomSprite
@ -67,9 +87,137 @@ DoomEdNums
9997 = SecActExit
9998 = SecActEnter
9999 = SecActHitFloor
14001 = AmbientSound, 1
14002 = AmbientSound, 2
14003 = AmbientSound, 3
14004 = AmbientSound, 4
14005 = AmbientSound, 5
14006 = AmbientSound, 6
14007 = AmbientSound, 7
14008 = AmbientSound, 8
14009 = AmbientSound, 9
14010 = AmbientSound, 10
14011 = AmbientSound, 11
14012 = AmbientSound, 12
14013 = AmbientSound, 13
14014 = AmbientSound, 14
14015 = AmbientSound, 15
14016 = AmbientSound, 16
14017 = AmbientSound, 17
14018 = AmbientSound, 18
14019 = AmbientSound, 19
14020 = AmbientSound, 20
14021 = AmbientSound, 21
14022 = AmbientSound, 22
14023 = AmbientSound, 23
14024 = AmbientSound, 24
14025 = AmbientSound, 25
14026 = AmbientSound, 26
14027 = AmbientSound, 27
14028 = AmbientSound, 28
14029 = AmbientSound, 29
14030 = AmbientSound, 30
14031 = AmbientSound, 31
14032 = AmbientSound, 32
14033 = AmbientSound, 33
14034 = AmbientSound, 34
14035 = AmbientSound, 35
14036 = AmbientSound, 36
14037 = AmbientSound, 37
14038 = AmbientSound, 38
14039 = AmbientSound, 39
14040 = AmbientSound, 40
14041 = AmbientSound, 41
14042 = AmbientSound, 42
14043 = AmbientSound, 43
14044 = AmbientSound, 44
14045 = AmbientSound, 45
14046 = AmbientSound, 46
14047 = AmbientSound, 47
14048 = AmbientSound, 48
14049 = AmbientSound, 49
14050 = AmbientSound, 50
14051 = AmbientSound, 51
14052 = AmbientSound, 52
14053 = AmbientSound, 53
14054 = AmbientSound, 54
14055 = AmbientSound, 55
14056 = AmbientSound, 56
14057 = AmbientSound, 57
14058 = AmbientSound, 58
14059 = AmbientSound, 59
14060 = AmbientSound, 60
14061 = AmbientSound, 61
14062 = AmbientSound, 62
14063 = AmbientSound, 63
14064 = AmbientSound, 64
14065 = AmbientSound
14066 = SoundSequence
14067 = AmbientSoundNoGravity
14101 = MusicChanger, 1
14102 = MusicChanger, 2
14103 = MusicChanger, 3
14104 = MusicChanger, 4
14105 = MusicChanger, 5
14106 = MusicChanger, 6
14107 = MusicChanger, 7
14108 = MusicChanger, 8
14109 = MusicChanger, 9
14110 = MusicChanger, 10
14111 = MusicChanger, 11
14112 = MusicChanger, 12
14113 = MusicChanger, 13
14114 = MusicChanger, 14
14115 = MusicChanger, 15
14116 = MusicChanger, 16
14117 = MusicChanger, 17
14118 = MusicChanger, 18
14119 = MusicChanger, 19
14120 = MusicChanger, 20
14121 = MusicChanger, 21
14122 = MusicChanger, 22
14123 = MusicChanger, 23
14124 = MusicChanger, 24
14125 = MusicChanger, 25
14126 = MusicChanger, 26
14127 = MusicChanger, 27
14128 = MusicChanger, 28
14129 = MusicChanger, 29
14130 = MusicChanger, 30
14131 = MusicChanger, 31
14132 = MusicChanger, 32
14133 = MusicChanger, 33
14134 = MusicChanger, 34
14135 = MusicChanger, 35
14136 = MusicChanger, 36
14137 = MusicChanger, 37
14138 = MusicChanger, 38
14139 = MusicChanger, 39
14140 = MusicChanger, 40
14141 = MusicChanger, 41
14142 = MusicChanger, 42
14143 = MusicChanger, 43
14144 = MusicChanger, 44
14145 = MusicChanger, 45
14146 = MusicChanger, 46
14147 = MusicChanger, 47
14148 = MusicChanger, 48
14149 = MusicChanger, 49
14150 = MusicChanger, 50
14151 = MusicChanger, 51
14152 = MusicChanger, 52
14153 = MusicChanger, 53
14154 = MusicChanger, 54
14155 = MusicChanger, 55
14156 = MusicChanger, 56
14157 = MusicChanger, 57
14158 = MusicChanger, 58
14159 = MusicChanger, 59
14160 = MusicChanger, 60
14161 = MusicChanger, 61
14162 = MusicChanger, 62
14163 = MusicChanger, 63
14164 = MusicChanger, 64
14165 = MusicChanger
32000 = DoomBuilderCamera
}

View file

@ -42,7 +42,6 @@ gameinfo
defaultrespawntime = 12
defaultdropstyle = 1
endoom = "ENDOOM"
player5start = 4001
pickupcolor = "d7 ba 45"
quitmessages = "$QUITMSG", "$QUITMSG1", "$QUITMSG2", "$QUITMSG3", "$QUITMSG4", "$QUITMSG5", "$QUITMSG6", "$QUITMSG7",
"$QUITMSG8", "$QUITMSG9", "$QUITMSG10", "$QUITMSG11", "$QUITMSG12", "$QUITMSG13", "$QUITMSG14"

View file

@ -119,6 +119,10 @@ DoomEdNums
3004 = Zombieman
3005 = Cacodemon
3006 = LostSoul
4001 = "$Player5Start"
4002 = "$Player6Start"
4003 = "$Player7Start"
4004 = "$Player8Start"
5010 = Pistol
5050 = Stalagmite
9050 = StealthArachnotron

View file

@ -41,7 +41,6 @@ gameinfo
defaultrespawntime = 12
defaultdropstyle = 1
endoom = "ENDTEXT"
player5start = 4001
pickupcolor = "d7 ba 45"
quitmessages = "$*RAVENQUITMSG"
menufontcolor_title = "UNTRANSLATED"
@ -159,6 +158,10 @@ DoomEdNums
2004 = SkullRod
2005 = Gauntlets
2035 = Pod
4001 = "$Player5Start"
4002 = "$Player6Start"
4003 = "$Player7Start"
4004 = "$Player8Start"
9042 = GoldWand
}

View file

@ -39,7 +39,6 @@ gameinfo
definventorymaxamount = 25
defaultrespawntime = 12
defaultdropstyle = 1
player5start = 9100
pickupcolor = "d7 ba 45"
quitmessages = "$*RAVENQUITMSG"
menufontcolor_title = "UNTRANSLATED"
@ -181,6 +180,9 @@ DoomEdNums
140 = TeleSmoke
254 = Dragon
1410 = SoundWindHexen
3000 = "$PolyAnchor"
3001 = "$PolySpawn"
3002 = "$PolySpawnCrush"
8000 = ArtiPoisonBag
8002 = ArtiSpeedBoots
8003 = ArtiBoostMana
@ -269,6 +271,10 @@ DoomEdNums
9019 = PuzzGear2
9020 = PuzzGear3
9021 = PuzzGear4
9100 = "$Player5Start"
9101 = "$Player6Start"
9102 = "$Player7Start"
9103 = "$Player8Start"
10000 = FogSpawner
10001 = FogPatchSmall
10002 = FogPatchMedium

View file

@ -68,6 +68,10 @@ gameinfo
DoomEdNums
{
5 = "$Player5Start"
6 = "$Player6Start"
7 = "$Player7Start"
8 = "$Player8Start"
9 = Rebel1
10 = TeleporterBeacon
12 = Loremaster
@ -170,6 +174,16 @@ DoomEdNums
115 = PoisonBolts
116 = WeaponSmith
117 = SurgeryCrab
118 = "$Player1Start", 1
119 = "$Player1Start", 2
120 = "$Player1Start", 3
121 = "$Player1Start", 4
122 = "$Player1Start", 5
123 = "$Player1Start", 6
124 = "$Player1Start", 7
125 = "$Player1Start", 8
126 = "$Player1Start", 9
127 = "$Player1Start", 10
128 = EntityBoss
129 = AlienSpectre1
130 = Peasant2