2015-04-03 08:54:55 +00:00
|
|
|
/*
|
|
|
|
** g_doomedmap.cpp
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
** Copyright 1998-2015 Randy Heit
|
|
|
|
** Copyright 2015 Christoph Oelckers
|
|
|
|
** All rights reserved.
|
|
|
|
**
|
|
|
|
** Redistribution and use in source and binary forms, with or without
|
|
|
|
** modification, are permitted provided that the following conditions
|
|
|
|
** are met:
|
|
|
|
**
|
|
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer.
|
|
|
|
** 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer in the
|
|
|
|
** documentation and/or other materials provided with the distribution.
|
|
|
|
** 3. The name of the author may not be used to endorse or promote products
|
|
|
|
** derived from this software without specific prior written permission.
|
|
|
|
**
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "info.h"
|
2015-04-03 14:51:45 +00:00
|
|
|
#include "p_lnspec.h"
|
2015-04-03 08:54:55 +00:00
|
|
|
#include "m_fixed.h"
|
|
|
|
#include "c_dispatch.h"
|
|
|
|
#include "templates.h"
|
|
|
|
#include "cmdlib.h"
|
|
|
|
#include "g_level.h"
|
2015-04-03 14:51:45 +00:00
|
|
|
#include "v_text.h"
|
|
|
|
#include "i_system.h"
|
2015-04-03 08:54:55 +00:00
|
|
|
|
2015-04-03 19:17:10 +00:00
|
|
|
|
|
|
|
const char *SpecialMapthingNames[] = {
|
2015-04-04 08:25:01 +00:00
|
|
|
"$Player1Start",
|
|
|
|
"$Player2Start",
|
|
|
|
"$Player3Start",
|
|
|
|
"$Player4Start",
|
|
|
|
"$Player5Start",
|
|
|
|
"$Player6Start",
|
|
|
|
"$Player7Start",
|
|
|
|
"$Player8Start",
|
|
|
|
"$DeathmatchStart",
|
|
|
|
"$SSeqOverride",
|
|
|
|
"$PolyAnchor",
|
|
|
|
"$PolySpawn",
|
|
|
|
"$PolySpawnCrush",
|
|
|
|
"$PolySpawnHurt",
|
|
|
|
"$SlopeFloorPointLine",
|
|
|
|
"$SlopeCeilingPointLine",
|
|
|
|
"$SetFloorSlope",
|
|
|
|
"$SetCeilingSlope",
|
|
|
|
"$VavoomFloor",
|
|
|
|
"$VavoomCeiling",
|
|
|
|
"$CopyFloorPlane",
|
|
|
|
"$CopyCeilingPlane",
|
|
|
|
"$VertexFloorZ",
|
|
|
|
"$VertexCeilingZ",
|
|
|
|
|
2015-04-03 19:17:10 +00:00
|
|
|
};
|
2015-04-03 08:54:55 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
2015-04-03 14:51:45 +00:00
|
|
|
// Stuff that's only valid during definition time
|
2015-04-03 08:54:55 +00:00
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2015-04-03 14:51:45 +00:00
|
|
|
struct MapinfoEdMapItem
|
|
|
|
{
|
|
|
|
FName classname; // DECORATE is read after MAPINFO so we do not have the actual classes available here yet.
|
2015-04-07 14:27:57 +00:00
|
|
|
short special;
|
2016-01-04 10:52:07 +00:00
|
|
|
signed char argsdefined;
|
2015-04-03 14:51:45 +00:00
|
|
|
int args[5];
|
|
|
|
// These are for error reporting. We must store the file information because it's no longer available when these items get resolved.
|
|
|
|
FString filename;
|
|
|
|
int linenum;
|
|
|
|
};
|
2015-04-03 08:54:55 +00:00
|
|
|
|
2015-04-03 14:51:45 +00:00
|
|
|
typedef TMap<int, MapinfoEdMapItem> IdMap;
|
2015-04-03 08:54:55 +00:00
|
|
|
|
2015-04-03 14:51:45 +00:00
|
|
|
static IdMap DoomEdFromMapinfo;
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2015-04-03 08:54:55 +00:00
|
|
|
|
2015-04-03 14:51:45 +00:00
|
|
|
FDoomEdMap DoomEdMap;
|
|
|
|
|
|
|
|
static int STACK_ARGS sortnums (const void *a, const void *b)
|
2015-04-03 08:54:55 +00:00
|
|
|
{
|
2015-04-03 14:51:45 +00:00
|
|
|
return (*(const FDoomEdMap::Pair**)a)->Key - (*(const FDoomEdMap::Pair**)b)->Key;
|
2015-04-03 08:54:55 +00:00
|
|
|
}
|
|
|
|
|
2015-04-03 14:51:45 +00:00
|
|
|
CCMD (dumpmapthings)
|
2015-04-03 08:54:55 +00:00
|
|
|
{
|
2015-04-03 14:51:45 +00:00
|
|
|
TArray<FDoomEdMap::Pair*> infos(DoomEdMap.CountUsed());
|
|
|
|
FDoomEdMap::Iterator it(DoomEdMap);
|
|
|
|
FDoomEdMap::Pair *pair;
|
|
|
|
|
|
|
|
while (it.NextPair(pair))
|
2015-04-03 08:54:55 +00:00
|
|
|
{
|
2015-04-03 14:51:45 +00:00
|
|
|
infos.Push(pair);
|
2015-04-03 08:54:55 +00:00
|
|
|
}
|
2015-04-03 14:51:45 +00:00
|
|
|
|
|
|
|
if (infos.Size () == 0)
|
2015-04-03 08:54:55 +00:00
|
|
|
{
|
2015-04-03 14:51:45 +00:00
|
|
|
Printf ("No map things registered\n");
|
2015-04-03 08:54:55 +00:00
|
|
|
}
|
2015-04-03 14:51:45 +00:00
|
|
|
else
|
2015-04-03 08:54:55 +00:00
|
|
|
{
|
2015-04-03 14:51:45 +00:00
|
|
|
qsort (&infos[0], infos.Size (), sizeof(FDoomEdMap::Pair*), sortnums);
|
2015-04-03 08:54:55 +00:00
|
|
|
|
2015-04-03 14:51:45 +00:00
|
|
|
for (unsigned i = 0; i < infos.Size (); ++i)
|
2015-04-03 08:54:55 +00:00
|
|
|
{
|
2015-04-03 20:23:42 +00:00
|
|
|
if (infos[i]->Value.Type != NULL)
|
|
|
|
{
|
|
|
|
Printf("%6d %s\n", infos[i]->Key, infos[i]->Value.Type->TypeName.GetChars());
|
|
|
|
}
|
|
|
|
else if (infos[i]->Value.Special > 0)
|
|
|
|
{
|
|
|
|
Printf("%6d %s\n", infos[i]->Key, SpecialMapthingNames[infos[i]->Value.Special - 1]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-09-14 14:22:41 +00:00
|
|
|
Printf("%6d none\n", infos[i]->Key);
|
2015-04-03 20:23:42 +00:00
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-03 14:51:45 +00:00
|
|
|
void FMapInfoParser::ParseDoomEdNums()
|
2015-04-03 08:54:55 +00:00
|
|
|
{
|
2015-04-03 14:51:45 +00:00
|
|
|
TMap<int, bool> defined;
|
|
|
|
int error = 0;
|
2015-04-03 08:54:55 +00:00
|
|
|
|
2015-04-03 14:51:45 +00:00
|
|
|
MapinfoEdMapItem editem;
|
2015-04-03 08:54:55 +00:00
|
|
|
|
2015-04-03 14:51:45 +00:00
|
|
|
editem.filename = sc.ScriptName;
|
2015-04-03 08:54:55 +00:00
|
|
|
|
2015-04-03 19:17:10 +00:00
|
|
|
ParseOpenBrace();
|
2015-04-03 14:51:45 +00:00
|
|
|
while (true)
|
2015-04-03 08:54:55 +00:00
|
|
|
{
|
2015-04-03 14:51:45 +00:00
|
|
|
if (sc.CheckString("}")) return;
|
|
|
|
else if (sc.CheckNumber())
|
|
|
|
{
|
|
|
|
int ednum = sc.Number;
|
|
|
|
sc.MustGetStringName("=");
|
|
|
|
sc.MustGetString();
|
|
|
|
|
|
|
|
bool *def = defined.CheckKey(ednum);
|
|
|
|
if (def != NULL)
|
|
|
|
{
|
|
|
|
sc.ScriptMessage("Editor Number %d defined more than once", ednum);
|
|
|
|
error++;
|
|
|
|
}
|
|
|
|
defined[ednum] = true;
|
|
|
|
if (sc.String[0] == '$')
|
|
|
|
{
|
|
|
|
// todo: add special stuff like playerstarts and sound sequence overrides here, too.
|
|
|
|
editem.classname = NAME_None;
|
2015-04-03 19:17:10 +00:00
|
|
|
editem.special = sc.MustMatchString(SpecialMapthingNames) + 1; // todo: assign proper constants
|
2015-04-03 14:51:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
editem.classname = sc.String;
|
|
|
|
editem.special = -1;
|
|
|
|
}
|
|
|
|
memset(editem.args, 0, sizeof(editem.args));
|
2016-01-04 10:52:07 +00:00
|
|
|
editem.argsdefined = 0;
|
2015-04-03 14:51:45 +00:00
|
|
|
|
|
|
|
int minargs = 0;
|
|
|
|
int maxargs = 5;
|
|
|
|
FString specialname;
|
|
|
|
if (sc.CheckString(","))
|
|
|
|
{
|
2016-01-04 10:52:07 +00:00
|
|
|
editem.argsdefined = 5; // mark args as used - if this is done we need to prevent assignment of map args in P_SpawnMapThing.
|
2015-04-07 14:27:57 +00:00
|
|
|
if (editem.special < 0) editem.special = 0;
|
2015-04-03 14:51:45 +00:00
|
|
|
if (!sc.CheckNumber())
|
|
|
|
{
|
|
|
|
sc.MustGetString();
|
|
|
|
specialname = sc.String; // save for later error reporting.
|
|
|
|
editem.special = P_FindLineSpecial(sc.String, &minargs, &maxargs);
|
|
|
|
if (editem.special == 0 || minargs == -1)
|
|
|
|
{
|
|
|
|
sc.ScriptMessage("Invalid special %s for Editor Number %d", sc.String, ednum);
|
|
|
|
error++;
|
|
|
|
minargs = 0;
|
|
|
|
maxargs = 5;
|
|
|
|
}
|
|
|
|
if (!sc.CheckString(","))
|
|
|
|
{
|
|
|
|
// special case: Special without arguments
|
|
|
|
if (minargs != 0)
|
|
|
|
{
|
|
|
|
sc.ScriptMessage("Incorrect number of args for special %s, min = %d, max = %d, found = 0", specialname.GetChars(), minargs, maxargs);
|
|
|
|
error++;
|
|
|
|
}
|
|
|
|
DoomEdFromMapinfo.Insert(ednum, editem);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
sc.MustGetNumber();
|
|
|
|
}
|
|
|
|
int i = 0;
|
|
|
|
while (i < 5)
|
|
|
|
{
|
2015-04-20 21:20:56 +00:00
|
|
|
editem.args[i] = sc.Number;
|
2015-04-03 14:51:45 +00:00
|
|
|
i++;
|
|
|
|
if (!sc.CheckString(",")) break;
|
2016-01-04 10:52:07 +00:00
|
|
|
// special check for the ambient sounds which combine the arg being set here with the ones on the mapthing.
|
|
|
|
if (sc.CheckString("+"))
|
|
|
|
{
|
|
|
|
editem.argsdefined = i;
|
|
|
|
break;
|
|
|
|
}
|
2015-04-03 14:51:45 +00:00
|
|
|
sc.MustGetNumber();
|
2016-01-04 10:52:07 +00:00
|
|
|
|
2015-04-03 14:51:45 +00:00
|
|
|
}
|
|
|
|
if (specialname.IsNotEmpty() && (i < minargs || i > maxargs))
|
|
|
|
{
|
|
|
|
sc.ScriptMessage("Incorrect number of args for special %s, min = %d, max = %d, found = %d", specialname.GetChars(), minargs, maxargs, i);
|
|
|
|
error++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DoomEdFromMapinfo.Insert(ednum, editem);
|
|
|
|
}
|
|
|
|
else
|
2015-04-03 08:54:55 +00:00
|
|
|
{
|
2015-04-03 14:51:45 +00:00
|
|
|
sc.ScriptError("Number expected");
|
2015-04-03 08:54:55 +00:00
|
|
|
}
|
|
|
|
}
|
2015-04-03 14:51:45 +00:00
|
|
|
if (error > 0)
|
2015-04-03 08:54:55 +00:00
|
|
|
{
|
2015-04-03 14:51:45 +00:00
|
|
|
sc.ScriptError("%d errors encountered in DoomEdNum definition");
|
2015-04-03 08:54:55 +00:00
|
|
|
}
|
2015-04-03 14:51:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void InitActorNumsFromMapinfo()
|
|
|
|
{
|
|
|
|
DoomEdMap.Clear();
|
|
|
|
IdMap::Iterator it(DoomEdFromMapinfo);
|
|
|
|
IdMap::Pair *pair;
|
|
|
|
int error = 0;
|
2015-04-03 08:54:55 +00:00
|
|
|
|
2015-04-03 14:51:45 +00:00
|
|
|
while (it.NextPair(pair))
|
|
|
|
{
|
2015-04-28 10:48:33 +00:00
|
|
|
PClassActor *cls = NULL;
|
2015-04-03 14:51:45 +00:00
|
|
|
if (pair->Value.classname != NAME_None)
|
2015-04-03 08:54:55 +00:00
|
|
|
{
|
2015-04-28 10:48:33 +00:00
|
|
|
cls = PClass::FindActor(pair->Value.classname);
|
2015-04-03 14:51:45 +00:00
|
|
|
if (cls == NULL)
|
|
|
|
{
|
|
|
|
Printf(TEXTCOLOR_RED "Script error, \"%s\" line %d:\nUnknown actor class %s\n",
|
|
|
|
pair->Value.filename.GetChars(), pair->Value.linenum, pair->Value.classname.GetChars());
|
|
|
|
error++;
|
|
|
|
}
|
2015-04-03 08:54:55 +00:00
|
|
|
}
|
2015-04-03 14:51:45 +00:00
|
|
|
FDoomEdEntry ent;
|
|
|
|
ent.Type = cls;
|
|
|
|
ent.Special = pair->Value.special;
|
2015-04-07 14:27:57 +00:00
|
|
|
ent.ArgsDefined = pair->Value.argsdefined;
|
2015-04-03 14:51:45 +00:00
|
|
|
memcpy(ent.Args, pair->Value.args, sizeof(ent.Args));
|
|
|
|
DoomEdMap.Insert(pair->Key, ent);
|
2015-04-03 08:54:55 +00:00
|
|
|
}
|
2015-04-03 14:51:45 +00:00
|
|
|
if (error > 0)
|
|
|
|
{
|
|
|
|
I_Error("%d unknown actor classes found", error);
|
|
|
|
}
|
|
|
|
DoomEdFromMapinfo.Clear(); // we do not need this any longer
|
2015-04-03 08:54:55 +00:00
|
|
|
}
|