2009-05-08 13:28:41 +00:00
|
|
|
/*
|
|
|
|
* OpenClonk, http://www.openclonk.org
|
|
|
|
*
|
2009-06-05 13:41:20 +00:00
|
|
|
* Copyright (c) 1998-2000 Matthes Bender
|
|
|
|
* Copyright (c) 2001 Sven Eberhardt
|
|
|
|
* Copyright (c) 2008 Günther Brammer
|
2010-12-23 00:01:24 +00:00
|
|
|
* Copyright (c) 2009-2010 Nicolas Hake
|
|
|
|
* Copyright (c) 2010 Benjamin Herr
|
2009-05-08 13:28:41 +00:00
|
|
|
* Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de
|
|
|
|
*
|
|
|
|
* Portions might be copyrighted by other authors who have contributed
|
|
|
|
* to OpenClonk.
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
* See isc_license.txt for full license and disclaimer.
|
|
|
|
*
|
|
|
|
* "Clonk" is a registered trademark of Matthes Bender.
|
|
|
|
* See clonk_trademark_license.txt for full license.
|
|
|
|
*/
|
|
|
|
|
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"
|
|
|
|
#include "C4Id.h"
|
|
|
|
#include "StdCompiler.h"
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2010-01-25 15:57:57 +00:00
|
|
|
#include <utility>
|
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"));
|
2010-03-23 13:57:52 +00:00
|
|
|
|
|
|
|
// TODO: Remove these eventually, since they are deprecated.
|
|
|
|
const C4ID C4ID::CnMaterial(std::string("CNMT"));
|
|
|
|
const C4ID C4ID::Flag(std::string("FLAG"));
|
|
|
|
const C4ID C4ID::Conkit(std::string("CNKT"));
|
|
|
|
const C4ID C4ID::Flame(std::string("FLAM"));
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
if (pComp->isDecompiler())
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|