Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/simulation2/scripting/MessageTypeConversions.cpp
Show First 20 Lines • Show All 259 Lines • ▼ Show 20 Lines | CMessage* CMessageTerritoryPositionChanged::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val) | ||||
GET_MSG_PROPERTY(entity_id_t, entity); | GET_MSG_PROPERTY(entity_id_t, entity); | ||||
GET_MSG_PROPERTY(player_id_t, newTerritory); | GET_MSG_PROPERTY(player_id_t, newTerritory); | ||||
return new CMessageTerritoryPositionChanged(entity, newTerritory); | return new CMessageTerritoryPositionChanged(entity, newTerritory); | ||||
} | } | ||||
//////////////////////////////// | //////////////////////////////// | ||||
const std::array<const char*, CMessageMotionUpdate::UpdateType::LENGTH> CMessageMotionUpdate::UpdateTypeStr = { { | const std::array<const char*, CMessageMotionUpdate::UpdateType::LENGTH> CMessageMotionUpdate::UpdateTypeStr = { { | ||||
"likelySuccess", "likelyFailure", "obstructed" | "likelySuccess", "likelyFailure", "obstructed", "veryObstructed" | ||||
} }; | } }; | ||||
JS::Value CMessageMotionUpdate::ToJSVal(const ScriptInterface& scriptInterface) const | JS::Value CMessageMotionUpdate::ToJSVal(const ScriptInterface& scriptInterface) const | ||||
{ | { | ||||
TOJSVAL_SETUP(); | TOJSVAL_SETUP(); | ||||
JS::RootedValue prop(rq.cx); | JS::RootedValue prop(rq.cx); | ||||
if (!JS_SetProperty(rq.cx, obj, UpdateTypeStr[updateType], JS::TrueHandleValue)) | if (!JS_SetProperty(rq.cx, obj, UpdateTypeStr[updateType], JS::TrueHandleValue)) | ||||
return JS::UndefinedValue(); | return JS::UndefinedValue(); | ||||
return JS::ObjectValue(*obj); | return JS::ObjectValue(*obj); | ||||
} | } | ||||
CMessage* CMessageMotionUpdate::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val) | CMessage* CMessageMotionUpdate::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val) | ||||
{ | { | ||||
FROMJSVAL_SETUP(); | FROMJSVAL_SETUP(); | ||||
GET_MSG_PROPERTY(std::wstring, updateString); | GET_MSG_PROPERTY(std::wstring, updateString); | ||||
if (updateString == L"likelySuccess") | if (updateString == L"likelySuccess") | ||||
return new CMessageMotionUpdate(CMessageMotionUpdate::LIKELY_SUCCESS); | return new CMessageMotionUpdate(CMessageMotionUpdate::LIKELY_SUCCESS); | ||||
if (updateString == L"likelyFailure") | if (updateString == L"likelyFailure") | ||||
return new CMessageMotionUpdate(CMessageMotionUpdate::LIKELY_FAILURE); | return new CMessageMotionUpdate(CMessageMotionUpdate::LIKELY_FAILURE); | ||||
if (updateString == L"obstructed") | if (updateString == L"obstructed") | ||||
return new CMessageMotionUpdate(CMessageMotionUpdate::OBSTRUCTED); | return new CMessageMotionUpdate(CMessageMotionUpdate::OBSTRUCTED); | ||||
if (updateString == L"veryObstructed") | |||||
return new CMessageMotionUpdate(CMessageMotionUpdate::VERY_OBSTRUCTED); | |||||
LOGWARNING("CMessageMotionUpdate::FromJSVal passed wrong updateString"); | LOGWARNING("CMessageMotionUpdate::FromJSVal passed wrong updateString"); | ||||
return NULL; | return NULL; | ||||
} | } | ||||
//////////////////////////////// | //////////////////////////////// | ||||
JS::Value CMessageTerrainChanged::ToJSVal(const ScriptInterface& scriptInterface) const | JS::Value CMessageTerrainChanged::ToJSVal(const ScriptInterface& scriptInterface) const | ||||
▲ Show 20 Lines • Show All 265 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator