2009-05-08 13:28:41 +00:00
|
|
|
/*
|
|
|
|
* OpenClonk, http://www.openclonk.org
|
|
|
|
*
|
2013-12-17 20:01:09 +00:00
|
|
|
* Copyright (c) 1998-2000, Matthes Bender
|
|
|
|
* Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
|
2016-04-03 18:18:29 +00:00
|
|
|
* Copyright (c) 2009-2016, The OpenClonk Team and contributors
|
2009-05-08 13:28:41 +00:00
|
|
|
*
|
2013-12-17 20:01:09 +00:00
|
|
|
* Distributed under the terms of the ISC license; see accompanying file
|
|
|
|
* "COPYING" for details.
|
2009-05-08 13:28:41 +00:00
|
|
|
*
|
2013-12-17 20:01:09 +00:00
|
|
|
* "Clonk" is a registered trademark of Matthes Bender, used with permission.
|
|
|
|
* See accompanying file "TRADEMARK" for details.
|
2009-05-08 13:28:41 +00:00
|
|
|
*
|
2013-12-17 20:01:09 +00:00
|
|
|
* To redistribute this file separately, substitute the full license texts
|
|
|
|
* for the above references.
|
2009-05-08 13:28:41 +00:00
|
|
|
*/
|
|
|
|
|
2010-01-25 15:57:57 +00:00
|
|
|
/* Value to identify object definitions */
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2010-01-25 15:57:57 +00:00
|
|
|
#include "C4Include.h"
|
2016-04-03 18:07:56 +00:00
|
|
|
#include "object/C4Id.h"
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2017-04-30 08:49:09 +00:00
|
|
|
#include "lib/StdCompiler.h"
|
2010-01-25 03:14:52 +00:00
|
|
|
|
2010-01-25 15:57:57 +00:00
|
|
|
C4ID::NamesList C4ID::names;
|
|
|
|
C4ID::LookupTable C4ID::lookup;
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2010-03-23 13:57:52 +00:00
|
|
|
const C4ID C4ID::None(std::string("None"));
|
2013-04-01 10:48:02 +00:00
|
|
|
const C4ID C4ID::Clonk(std::string("Clonk"));
|
|
|
|
const C4ID C4ID::Bubble(std::string("Fx_Bubble"));
|
2016-04-17 02:02:24 +00:00
|
|
|
const C4ID C4ID::EditorBase(std::string("EditorBase"));
|
2010-03-23 13:57:52 +00:00
|
|
|
|
|
|
|
// TODO: Remove these eventually, since they are deprecated.
|
|
|
|
const C4ID C4ID::Flag(std::string("FLAG"));
|
|
|
|
const C4ID C4ID::Conkit(std::string("CNKT"));
|
|
|
|
const C4ID C4ID::Melee(std::string("MELE"));
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2010-01-25 15:57:57 +00:00
|
|
|
C4ID::C4ID(const std::string &s) { assign(s); }
|
|
|
|
|
|
|
|
void C4ID::assign(const std::string &s)
|
|
|
|
{
|
|
|
|
LookupTable::const_iterator it = lookup.find(s);
|
|
|
|
if (it != lookup.end())
|
|
|
|
v = it->second;
|
|
|
|
else
|
2009-05-08 13:28:41 +00:00
|
|
|
{
|
2010-01-25 15:57:57 +00:00
|
|
|
v = names.size();
|
|
|
|
names.push_back(s);
|
|
|
|
lookup.insert(std::make_pair(s, v));
|
2009-05-08 13:28:41 +00:00
|
|
|
}
|
2010-01-25 15:57:57 +00:00
|
|
|
}
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2010-01-25 15:57:57 +00:00
|
|
|
void C4ID::CompileFunc(StdCompiler *pComp)
|
|
|
|
{
|
2017-03-11 14:05:41 +00:00
|
|
|
if (pComp->isSerializer())
|
2010-01-25 15:57:57 +00:00
|
|
|
{
|
|
|
|
assert(v < names.size());
|
2011-01-16 20:28:24 +00:00
|
|
|
pComp->String(&names[v][0], names[v].size(), StdCompiler::RCT_ID);
|
2010-01-25 15:57:57 +00:00
|
|
|
}
|
2009-05-08 13:28:41 +00:00
|
|
|
else
|
|
|
|
{
|
2010-01-25 15:57:57 +00:00
|
|
|
char *data;
|
2011-01-16 20:28:24 +00:00
|
|
|
pComp->String(&data, StdCompiler::RCT_ID);
|
2010-01-25 15:57:57 +00:00
|
|
|
v = C4ID(data).v;
|
|
|
|
StdBuf::DeletePointer(data);
|
2009-05-08 13:28:41 +00:00
|
|
|
}
|
2010-01-25 15:57:57 +00:00
|
|
|
}
|