0ad/source/scripting/SynchedJSObject.cpp
Matei fa229121ec Bug fixes and more game setup options.
- Added "Screenshot Mode" and "Fog of War" game attributes. (Screenshot
Mode causes units to be initialized to Hold stance instead of Aggress
and also forces LOS to be All Visible. Atlas turn on Screenshot Mode by
default so units don't try to kill each other in there.)
- Modified LOSManager to allow disabling fog of war.
- Removed some debug message spam.
- Enabled line antialiasing for aura rendering and fixed some bugs that
caused strange effects (color was not set properly for the center point,
and when a unit was both mouseover'ed and selected, the aura was drawn
twice).
- Modified Stand stance to allow retaliation on attacks (normally Stand
will attack any enemy in LOS, but this is useful if a neutral unit is in
LOS).
- Modified pathfinder to not take into account terrain slope, which is
an expensive calculation - we'll eventually take into account terrain
type instead.

This was SVN commit r4527.
2006-10-08 17:39:46 +00:00

107 lines
1.8 KiB
C++

#include "precompiled.h"
#include "SynchedJSObject.h"
#include "ps/Parser.h"
#include "ScriptCustomTypes.h"
template <>
CStrW ToNetString(const uint &val)
{
return CStrW(val);
}
template <>
void SetFromNetString(uint &val, const CStrW& string)
{
val=string.ToUInt();
}
template <>
CStrW ToNetString(const int &val)
{
return CStrW(val);
}
template <>
void SetFromNetString(int &val, const CStrW& string)
{
val=string.ToInt();
}
template <>
CStrW ToNetString(const bool &val)
{
return val ? CStrW("true") : CStrW("false");
}
template <>
void SetFromNetString(bool &val, const CStrW& string)
{
val = (string == CStrW("true"));
}
template <>
CStrW ToNetString(const CStrW& data)
{
return data;
}
template <> void SetFromNetString(CStrW& data, const CStrW& string)
{
data=string;
}
template <>
CStrW ToNetString(const SColour &data)
{
wchar_t buf[256];
swprintf(buf, 256, L"%f %f %f %f", data.r, data.g, data.b, data.a);
buf[255]=0;
return CStrW(buf);
}
template <>
void SetFromNetString(SColour &data, const CStrW& wstring)
{
CParser &parser(CParserCache::Get("$value_$value_$value_$value"));
CParserLine line;
line.ParseString(parser, CStr(wstring));
float values[4];
if (line.GetArgCount() != 4) return;
for (uint i=0; i<4; ++i)
{
if (!line.GetArgFloat(i, values[i]))
{
return;
}
}
data.r = values[0];
data.g = values[1];
data.b = values[2];
data.a = values[3];
}
void CSynchedJSObjectBase::IterateSynchedProperties(IterateCB *cb, void *userdata)
{
SynchedPropertyIterator it=m_SynchedProperties.begin();
while (it != m_SynchedProperties.end())
{
cb(it->first, it->second, userdata);
++it;
}
}
ISynchedJSProperty *CSynchedJSObjectBase::GetSynchedProperty(const CStrW& name)
{
SynchedPropertyIterator prop=m_SynchedProperties.find(name);
if (prop != m_SynchedProperties.end())
return prop->second;
else
return NULL;
}