Merge commit '2ec8e2c2ac' into scripting

Conflicts:
	src/d_main.cpp
	src/info.cpp
	src/p_local.h

(Had to merge this all by itself because it was creating too many merge conflicts when combined with other stuff.
This commit is contained in:
Christoph Oelckers 2015-04-28 12:54:01 +02:00
commit 0474560ac6
147 changed files with 423 additions and 1165 deletions

View file

@ -45,10 +45,23 @@
#include "gi.h"
#include "templates.h"
#include "g_level.h"
#include "v_text.h"
#include "i_system.h"
// Set of spawnable things for the Thing_Spawn and Thing_Projectile specials.
TMap<int, PClassActor *> SpawnableThings;
struct MapinfoSpawnItem
{
FName classname; // DECORATE is read after MAPINFO so we do not have the actual classes available here yet.
// 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;
};
typedef TMap<int, MapinfoSpawnItem> SpawnMap;
static SpawnMap SpawnablesFromMapinfo;
static FRandom pr_leadtarget ("LeadTarget");
bool P_Thing_Spawn (int tid, AActor *source, int type, angle_t angle, bool fog, int newtid)
@ -559,3 +572,77 @@ CCMD (dumpspawnables)
delete[] allpairs;
}
void FMapInfoParser::ParseSpawnNums()
{
TMap<int, bool> defined;
int error = 0;
MapinfoSpawnItem editem;
editem.filename = sc.ScriptName;
ParseOpenBrace();
while (true)
{
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("Spawn Number %d defined more than once", ednum);
error++;
}
else if (ednum < 0)
{
sc.ScriptMessage("Spawn Number must be positive, got %d", ednum);
error++;
}
defined[ednum] = true;
editem.classname = sc.String;
SpawnablesFromMapinfo.Insert(ednum, editem);
}
else
{
sc.ScriptError("Number expected");
}
}
if (error > 0)
{
sc.ScriptError("%d errors encountered in SpawnNum definition");
}
}
void InitSpawnablesFromMapinfo()
{
SpawnableThings.Clear();
SpawnMap::Iterator it(SpawnablesFromMapinfo);
SpawnMap::Pair *pair;
int error = 0;
while (it.NextPair(pair))
{
PClassActor *cls = NULL;
if (pair->Value.classname != NAME_None)
{
cls = PClass::FindActor(pair->Value.classname);
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++;
}
}
SpawnableThings.Insert(pair->Key, cls);
}
if (error > 0)
{
I_Error("%d unknown actor classes found", error);
}
SpawnablesFromMapinfo.Clear(); // we do not need this any longer
}