LCOV - code coverage report
Current view: top level - source/simulation2/scripting - MessageTypeConversions.cpp (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 11 264 4.2 %
Date: 2023-01-19 00:18:29 Functions: 5 66 7.6 %

          Line data    Source code
       1             : /* Copyright (C) 2021 Wildfire Games.
       2             :  * This file is part of 0 A.D.
       3             :  *
       4             :  * 0 A.D. is free software: you can redistribute it and/or modify
       5             :  * it under the terms of the GNU General Public License as published by
       6             :  * the Free Software Foundation, either version 2 of the License, or
       7             :  * (at your option) any later version.
       8             :  *
       9             :  * 0 A.D. is distributed in the hope that it will be useful,
      10             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      12             :  * GNU General Public License for more details.
      13             :  *
      14             :  * You should have received a copy of the GNU General Public License
      15             :  * along with 0 A.D.  If not, see <http://www.gnu.org/licenses/>.
      16             :  */
      17             : #include "precompiled.h"
      18             : 
      19             : #include "ps/CLogger.h"
      20             : #include "scriptinterface/ScriptConversions.h"
      21             : #include "simulation2/MessageTypes.h"
      22             : 
      23             : #define TOJSVAL_SETUP() \
      24             :     ScriptRequest rq(scriptInterface); \
      25             :     JS::RootedObject obj(rq.cx, JS_NewPlainObject(rq.cx)); \
      26             :     if (!obj) \
      27             :         return JS::UndefinedValue();
      28             : 
      29             : #define SET_MSG_PROPERTY(name) \
      30             :     do { \
      31             :         JS::RootedValue prop(rq.cx);\
      32             :         Script::ToJSVal(rq, &prop, this->name); \
      33             :         if (! JS_SetProperty(rq.cx, obj, #name, prop)) \
      34             :             return JS::UndefinedValue(); \
      35             :     } while (0);
      36             : 
      37             : #define FROMJSVAL_SETUP() \
      38             :     ScriptRequest rq(scriptInterface); \
      39             :     if (val.isPrimitive()) \
      40             :         return NULL; \
      41             :     JS::RootedObject obj(rq.cx, &val.toObject()); \
      42             :     JS::RootedValue prop(rq.cx);
      43             : 
      44             : #define GET_MSG_PROPERTY(type, name) \
      45             :     type name; \
      46             :     { \
      47             :     if (! JS_GetProperty(rq.cx, obj, #name, &prop)) \
      48             :         return NULL; \
      49             :     if (! Script::FromJSVal(rq, prop, name)) \
      50             :         return NULL; \
      51             :     }
      52             : 
      53          10 : JS::Value CMessage::ToJSValCached(const ScriptInterface& scriptInterface) const
      54             : {
      55          20 :     ScriptRequest rq(scriptInterface);
      56          10 :     if (!m_Cached)
      57           5 :         m_Cached.reset(new JS::PersistentRootedValue(rq.cx, ToJSVal(scriptInterface)));
      58             : 
      59          20 :     return m_Cached->get();
      60             : }
      61             : 
      62             : ////////////////////////////////
      63             : 
      64           1 : JS::Value CMessageTurnStart::ToJSVal(const ScriptInterface& scriptInterface) const
      65             : {
      66           2 :     TOJSVAL_SETUP();
      67           1 :     return JS::ObjectValue(*obj);
      68             : }
      69             : 
      70           0 : CMessage* CMessageTurnStart::FromJSVal(const ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
      71             : {
      72           0 :     return new CMessageTurnStart();
      73             : }
      74             : 
      75             : ////////////////////////////////
      76             : 
      77             : #define MESSAGE_1(name, t0, a0) \
      78             :     JS::Value CMessage##name::ToJSVal(const ScriptInterface& scriptInterface) const \
      79             :     { \
      80             :         TOJSVAL_SETUP(); \
      81             :         SET_MSG_PROPERTY(a0); \
      82             :         return JS::ObjectValue(*obj); \
      83             :     } \
      84             :     CMessage* CMessage##name::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val) \
      85             :     { \
      86             :         FROMJSVAL_SETUP(); \
      87             :         GET_MSG_PROPERTY(t0, a0); \
      88             :         return new CMessage##name(a0); \
      89             :     }
      90             : 
      91           7 : MESSAGE_1(Update, fixed, turnLength)
      92           0 : MESSAGE_1(Update_MotionFormation, fixed, turnLength)
      93           0 : MESSAGE_1(Update_MotionUnit, fixed, turnLength)
      94           0 : MESSAGE_1(Update_Final, fixed, turnLength)
      95             : 
      96             : ////////////////////////////////
      97             : 
      98           0 : JS::Value CMessageInterpolate::ToJSVal(const ScriptInterface& scriptInterface) const
      99             : {
     100           0 :     TOJSVAL_SETUP();
     101           0 :     SET_MSG_PROPERTY(deltaSimTime);
     102           0 :     SET_MSG_PROPERTY(offset);
     103           0 :     SET_MSG_PROPERTY(deltaRealTime);
     104           0 :     return JS::ObjectValue(*obj);
     105             : }
     106             : 
     107           0 : CMessage* CMessageInterpolate::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
     108             : {
     109           0 :     FROMJSVAL_SETUP();
     110           0 :     GET_MSG_PROPERTY(float, deltaSimTime);
     111           0 :     GET_MSG_PROPERTY(float, offset);
     112           0 :     GET_MSG_PROPERTY(float, deltaRealTime);
     113           0 :     return new CMessageInterpolate(deltaSimTime, offset, deltaRealTime);
     114             : }
     115             : 
     116             : ////////////////////////////////
     117             : 
     118           0 : JS::Value CMessageRenderSubmit::ToJSVal(const ScriptInterface& UNUSED(scriptInterface)) const
     119             : {
     120           0 :     LOGWARNING("CMessageRenderSubmit::ToJSVal not implemented");
     121           0 :     return JS::UndefinedValue();
     122             : }
     123             : 
     124           0 : CMessage* CMessageRenderSubmit::FromJSVal(const ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
     125             : {
     126           0 :     LOGWARNING("CMessageRenderSubmit::FromJSVal not implemented");
     127           0 :     return NULL;
     128             : }
     129             : 
     130             : ////////////////////////////////
     131             : 
     132           0 : JS::Value CMessageProgressiveLoad::ToJSVal(const ScriptInterface& UNUSED(scriptInterface)) const
     133             : {
     134           0 :     LOGWARNING("CMessageProgressiveLoad::ToJSVal not implemented");
     135           0 :     return JS::UndefinedValue();
     136             : }
     137             : 
     138           0 : CMessage* CMessageProgressiveLoad::FromJSVal(const ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
     139             : {
     140           0 :     LOGWARNING("CMessageProgressiveLoad::FromJSVal not implemented");
     141           0 :     return NULL;
     142             : }
     143             : 
     144             : ////////////////////////////////
     145             : 
     146           0 : JS::Value CMessageDeserialized::ToJSVal(const ScriptInterface& scriptInterface) const
     147             : {
     148           0 :     TOJSVAL_SETUP();
     149           0 :     return JS::ObjectValue(*obj);
     150             : }
     151             : 
     152           0 : CMessage* CMessageDeserialized::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
     153             : {
     154           0 :     FROMJSVAL_SETUP();
     155           0 :     return new CMessageDeserialized();
     156             : }
     157             : 
     158             : ////////////////////////////////
     159             : 
     160           0 : JS::Value CMessageCreate::ToJSVal(const ScriptInterface& scriptInterface) const
     161             : {
     162           0 :     TOJSVAL_SETUP();
     163           0 :     SET_MSG_PROPERTY(entity);
     164           0 :     return JS::ObjectValue(*obj);
     165             : }
     166             : 
     167           0 : CMessage* CMessageCreate::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
     168             : {
     169           0 :     FROMJSVAL_SETUP();
     170           0 :     GET_MSG_PROPERTY(entity_id_t, entity);
     171           0 :     return new CMessageCreate(entity);
     172             : }
     173             : 
     174             : ////////////////////////////////
     175             : 
     176           0 : JS::Value CMessageDestroy::ToJSVal(const ScriptInterface& scriptInterface) const
     177             : {
     178           0 :     TOJSVAL_SETUP();
     179           0 :     SET_MSG_PROPERTY(entity);
     180           0 :     return JS::ObjectValue(*obj);
     181             : }
     182             : 
     183           0 : CMessage* CMessageDestroy::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
     184             : {
     185           0 :     FROMJSVAL_SETUP();
     186           0 :     GET_MSG_PROPERTY(entity_id_t, entity);
     187           0 :     return new CMessageDestroy(entity);
     188             : }
     189             : 
     190             : ////////////////////////////////
     191             : 
     192           0 : JS::Value CMessageOwnershipChanged::ToJSVal(const ScriptInterface& scriptInterface) const
     193             : {
     194           0 :     TOJSVAL_SETUP();
     195           0 :     SET_MSG_PROPERTY(entity);
     196           0 :     SET_MSG_PROPERTY(from);
     197           0 :     SET_MSG_PROPERTY(to);
     198           0 :     return JS::ObjectValue(*obj);
     199             : }
     200             : 
     201           0 : CMessage* CMessageOwnershipChanged::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
     202             : {
     203           0 :     FROMJSVAL_SETUP();
     204           0 :     GET_MSG_PROPERTY(entity_id_t, entity);
     205           0 :     GET_MSG_PROPERTY(player_id_t, from);
     206           0 :     GET_MSG_PROPERTY(player_id_t, to);
     207           0 :     return new CMessageOwnershipChanged(entity, from, to);
     208             : }
     209             : 
     210             : ////////////////////////////////
     211             : 
     212           0 : JS::Value CMessagePositionChanged::ToJSVal(const ScriptInterface& scriptInterface) const
     213             : {
     214           0 :     TOJSVAL_SETUP();
     215           0 :     SET_MSG_PROPERTY(entity);
     216           0 :     SET_MSG_PROPERTY(inWorld);
     217           0 :     SET_MSG_PROPERTY(x);
     218           0 :     SET_MSG_PROPERTY(z);
     219           0 :     SET_MSG_PROPERTY(a);
     220           0 :     return JS::ObjectValue(*obj);
     221             : }
     222             : 
     223           0 : CMessage* CMessagePositionChanged::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
     224             : {
     225           0 :     FROMJSVAL_SETUP();
     226           0 :     GET_MSG_PROPERTY(entity_id_t, entity);
     227           0 :     GET_MSG_PROPERTY(bool, inWorld);
     228           0 :     GET_MSG_PROPERTY(entity_pos_t, x);
     229           0 :     GET_MSG_PROPERTY(entity_pos_t, z);
     230           0 :     GET_MSG_PROPERTY(entity_angle_t, a);
     231           0 :     return new CMessagePositionChanged(entity, inWorld, x, z, a);
     232             : }
     233             : 
     234             : ////////////////////////////////
     235             : 
     236           0 : JS::Value CMessageInterpolatedPositionChanged::ToJSVal(const ScriptInterface& UNUSED(scriptInterface)) const
     237             : {
     238           0 :     LOGWARNING("CMessageInterpolatedPositionChanged::ToJSVal not implemented");
     239           0 :     return JS::UndefinedValue();
     240             : }
     241             : 
     242           0 : CMessage* CMessageInterpolatedPositionChanged::FromJSVal(const ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
     243             : {
     244           0 :     LOGWARNING("CMessageInterpolatedPositionChanged::FromJSVal not implemented");
     245           0 :     return NULL;
     246             : }
     247             : 
     248             : ////////////////////////////////
     249             : 
     250           0 : JS::Value CMessageTerritoryPositionChanged::ToJSVal(const ScriptInterface& scriptInterface) const
     251             : {
     252           0 :     TOJSVAL_SETUP();
     253           0 :     SET_MSG_PROPERTY(entity);
     254           0 :     SET_MSG_PROPERTY(newTerritory);
     255           0 :     return JS::ObjectValue(*obj);
     256             : }
     257             : 
     258           0 : CMessage* CMessageTerritoryPositionChanged::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
     259             : {
     260           0 :     FROMJSVAL_SETUP();
     261           0 :     GET_MSG_PROPERTY(entity_id_t, entity);
     262           0 :     GET_MSG_PROPERTY(player_id_t, newTerritory);
     263           0 :     return new CMessageTerritoryPositionChanged(entity, newTerritory);
     264             : }
     265             : 
     266             : ////////////////////////////////
     267             : 
     268             : const std::array<const char*, CMessageMotionUpdate::UpdateType::LENGTH> CMessageMotionUpdate::UpdateTypeStr = { {
     269             :     "likelySuccess", "likelyFailure", "obstructed", "veryObstructed"
     270             : } };
     271             : 
     272           0 : JS::Value CMessageMotionUpdate::ToJSVal(const ScriptInterface& scriptInterface) const
     273             : {
     274           0 :     TOJSVAL_SETUP();
     275           0 :     JS::RootedValue prop(rq.cx);
     276             : 
     277           0 :     if (!JS_SetProperty(rq.cx, obj, UpdateTypeStr[updateType], JS::TrueHandleValue))
     278           0 :         return JS::UndefinedValue();
     279             : 
     280           0 :     return JS::ObjectValue(*obj);
     281             : }
     282             : 
     283           0 : CMessage* CMessageMotionUpdate::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
     284             : {
     285           0 :     FROMJSVAL_SETUP();
     286           0 :     GET_MSG_PROPERTY(std::wstring, updateString);
     287             : 
     288           0 :     if (updateString == L"likelySuccess")
     289           0 :         return new CMessageMotionUpdate(CMessageMotionUpdate::LIKELY_SUCCESS);
     290           0 :     if (updateString == L"likelyFailure")
     291           0 :         return new CMessageMotionUpdate(CMessageMotionUpdate::LIKELY_FAILURE);
     292           0 :     if (updateString == L"obstructed")
     293           0 :         return new CMessageMotionUpdate(CMessageMotionUpdate::OBSTRUCTED);
     294           0 :     if (updateString == L"veryObstructed")
     295           0 :         return new CMessageMotionUpdate(CMessageMotionUpdate::VERY_OBSTRUCTED);
     296             : 
     297           0 :     LOGWARNING("CMessageMotionUpdate::FromJSVal passed wrong updateString");
     298           0 :     return NULL;
     299             : }
     300             : 
     301             : ////////////////////////////////
     302             : 
     303           0 : JS::Value CMessageTerrainChanged::ToJSVal(const ScriptInterface& scriptInterface) const
     304             : {
     305           0 :     TOJSVAL_SETUP();
     306           0 :     SET_MSG_PROPERTY(i0);
     307           0 :     SET_MSG_PROPERTY(j0);
     308           0 :     SET_MSG_PROPERTY(i1);
     309           0 :     SET_MSG_PROPERTY(j1);
     310           0 :     return JS::ObjectValue(*obj);
     311             : }
     312             : 
     313           0 : CMessage* CMessageTerrainChanged::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
     314             : {
     315           0 :     FROMJSVAL_SETUP();
     316           0 :     GET_MSG_PROPERTY(int32_t, i0);
     317           0 :     GET_MSG_PROPERTY(int32_t, j0);
     318           0 :     GET_MSG_PROPERTY(int32_t, i1);
     319           0 :     GET_MSG_PROPERTY(int32_t, j1);
     320           0 :     return new CMessageTerrainChanged(i0, i1, j0, j1);
     321             : }
     322             : 
     323             : ////////////////////////////////
     324             : 
     325           0 : JS::Value CMessageVisibilityChanged::ToJSVal(const ScriptInterface& scriptInterface) const
     326             : {
     327           0 :     TOJSVAL_SETUP();
     328           0 :     SET_MSG_PROPERTY(player);
     329           0 :     SET_MSG_PROPERTY(ent);
     330           0 :     SET_MSG_PROPERTY(oldVisibility);
     331           0 :     SET_MSG_PROPERTY(newVisibility);
     332           0 :     return JS::ObjectValue(*obj);
     333             : }
     334             : 
     335           0 : CMessage* CMessageVisibilityChanged::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
     336             : {
     337           0 :     FROMJSVAL_SETUP();
     338           0 :     GET_MSG_PROPERTY(player_id_t, player);
     339           0 :     GET_MSG_PROPERTY(entity_id_t, ent);
     340           0 :     GET_MSG_PROPERTY(int, oldVisibility);
     341           0 :     GET_MSG_PROPERTY(int, newVisibility);
     342           0 :     return new CMessageVisibilityChanged(player, ent, oldVisibility, newVisibility);
     343             : }
     344             : 
     345             : ////////////////////////////////
     346             : 
     347           0 : JS::Value CMessageWaterChanged::ToJSVal(const ScriptInterface& scriptInterface) const
     348             : {
     349           0 :     TOJSVAL_SETUP();
     350           0 :     return JS::ObjectValue(*obj);
     351             : }
     352             : 
     353           0 : CMessage* CMessageWaterChanged::FromJSVal(const ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
     354             : {
     355           0 :     return new CMessageWaterChanged();
     356             : }
     357             : 
     358             : ////////////////////////////////
     359             : 
     360           0 : JS::Value CMessageMovementObstructionChanged::ToJSVal(const ScriptInterface& scriptInterface) const
     361             : {
     362           0 :     TOJSVAL_SETUP();
     363           0 :     return JS::ObjectValue(*obj);
     364             : }
     365             : 
     366           0 : CMessage* CMessageMovementObstructionChanged::FromJSVal(const ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
     367             : {
     368           0 :     return new CMessageMovementObstructionChanged();
     369             : }
     370             : 
     371             : ////////////////////////////////
     372             : 
     373           0 : JS::Value CMessageObstructionMapShapeChanged::ToJSVal(const ScriptInterface& scriptInterface) const
     374             : {
     375           0 :     TOJSVAL_SETUP();
     376           0 :     return JS::ObjectValue(*obj);
     377             : }
     378             : 
     379           0 : CMessage* CMessageObstructionMapShapeChanged::FromJSVal(const ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
     380             : {
     381           0 :     return new CMessageObstructionMapShapeChanged();
     382             : }
     383             : 
     384             : ////////////////////////////////
     385             : 
     386           0 : JS::Value CMessageTerritoriesChanged::ToJSVal(const ScriptInterface& scriptInterface) const
     387             : {
     388           0 :     TOJSVAL_SETUP();
     389           0 :     return JS::ObjectValue(*obj);
     390             : }
     391             : 
     392           0 : CMessage* CMessageTerritoriesChanged::FromJSVal(const ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
     393             : {
     394           0 :     return new CMessageTerritoriesChanged();
     395             : }
     396             : 
     397             : ////////////////////////////////
     398             : 
     399           0 : JS::Value CMessageRangeUpdate::ToJSVal(const ScriptInterface& scriptInterface) const
     400             : {
     401           0 :     TOJSVAL_SETUP();
     402           0 :     SET_MSG_PROPERTY(tag);
     403           0 :     SET_MSG_PROPERTY(added);
     404           0 :     SET_MSG_PROPERTY(removed);
     405           0 :     return JS::ObjectValue(*obj);
     406             : }
     407             : 
     408           0 : CMessage* CMessageRangeUpdate::FromJSVal(const ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
     409             : {
     410           0 :     LOGWARNING("CMessageRangeUpdate::FromJSVal not implemented");
     411           0 :     return NULL;
     412             : }
     413             : 
     414             : ////////////////////////////////
     415             : 
     416           0 : JS::Value CMessagePathResult::ToJSVal(const ScriptInterface& UNUSED(scriptInterface)) const
     417             : {
     418           0 :     LOGWARNING("CMessagePathResult::ToJSVal not implemented");
     419           0 :     return JS::UndefinedValue();
     420             : }
     421             : 
     422           0 : CMessage* CMessagePathResult::FromJSVal(const ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
     423             : {
     424           0 :     LOGWARNING("CMessagePathResult::FromJSVal not implemented");
     425           0 :     return NULL;
     426             : }
     427             : 
     428             : ////////////////////////////////
     429             : 
     430           0 : JS::Value CMessageValueModification::ToJSVal(const ScriptInterface& scriptInterface) const
     431             : {
     432           0 :     TOJSVAL_SETUP();
     433           0 :     SET_MSG_PROPERTY(entities);
     434           0 :     SET_MSG_PROPERTY(component);
     435           0 :     SET_MSG_PROPERTY(valueNames);
     436           0 :     return JS::ObjectValue(*obj);
     437             : }
     438             : 
     439           0 : CMessage* CMessageValueModification::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
     440             : {
     441           0 :     FROMJSVAL_SETUP();
     442           0 :     GET_MSG_PROPERTY(std::vector<entity_id_t>, entities);
     443           0 :     GET_MSG_PROPERTY(std::wstring, component);
     444           0 :     GET_MSG_PROPERTY(std::vector<std::wstring>, valueNames);
     445           0 :     return new CMessageValueModification(entities, component, valueNames);
     446             : }
     447             : 
     448             : ////////////////////////////////
     449             : 
     450           0 : JS::Value CMessageTemplateModification::ToJSVal(const ScriptInterface& scriptInterface) const
     451             : {
     452           0 :     TOJSVAL_SETUP();
     453           0 :     SET_MSG_PROPERTY(player);
     454           0 :     SET_MSG_PROPERTY(component);
     455           0 :     SET_MSG_PROPERTY(valueNames);
     456           0 :     return JS::ObjectValue(*obj);
     457             : }
     458             : 
     459           0 : CMessage* CMessageTemplateModification::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
     460             : {
     461           0 :     FROMJSVAL_SETUP();
     462           0 :     GET_MSG_PROPERTY(player_id_t, player);
     463           0 :     GET_MSG_PROPERTY(std::wstring, component);
     464           0 :     GET_MSG_PROPERTY(std::vector<std::wstring>, valueNames);
     465           0 :     return new CMessageTemplateModification(player, component, valueNames);
     466             : }
     467             : 
     468             : ////////////////////////////////
     469             : 
     470           0 : JS::Value CMessageVisionRangeChanged::ToJSVal(const ScriptInterface& scriptInterface) const
     471             : {
     472           0 :     TOJSVAL_SETUP();
     473           0 :     SET_MSG_PROPERTY(entity);
     474           0 :     SET_MSG_PROPERTY(oldRange);
     475           0 :     SET_MSG_PROPERTY(newRange);
     476           0 :     return JS::ObjectValue(*obj);
     477             : }
     478             : 
     479           0 : CMessage* CMessageVisionRangeChanged::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
     480             : {
     481           0 :     FROMJSVAL_SETUP();
     482           0 :     GET_MSG_PROPERTY(entity_id_t, entity);
     483           0 :     GET_MSG_PROPERTY(entity_pos_t, oldRange);
     484           0 :     GET_MSG_PROPERTY(entity_pos_t, newRange);
     485           0 :     return new CMessageVisionRangeChanged(entity, oldRange, newRange);
     486             : }
     487             : 
     488           0 : JS::Value CMessageVisionSharingChanged::ToJSVal(const ScriptInterface& scriptInterface) const
     489             : {
     490           0 :     TOJSVAL_SETUP();
     491           0 :     SET_MSG_PROPERTY(entity);
     492           0 :     SET_MSG_PROPERTY(player);
     493           0 :     SET_MSG_PROPERTY(add);
     494           0 :     return JS::ObjectValue(*obj);
     495             : }
     496             : 
     497           0 : CMessage* CMessageVisionSharingChanged::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
     498             : {
     499           0 :     FROMJSVAL_SETUP();
     500           0 :     GET_MSG_PROPERTY(entity_id_t, entity);
     501           0 :     GET_MSG_PROPERTY(player_id_t, player);
     502           0 :     GET_MSG_PROPERTY(bool, add);
     503           0 :     return new CMessageVisionSharingChanged(entity, player, add);
     504             : }
     505             : 
     506             : ////////////////////////////////
     507             : 
     508           0 : JS::Value CMessageMinimapPing::ToJSVal(const ScriptInterface& scriptInterface) const
     509             : {
     510           0 :     TOJSVAL_SETUP();
     511           0 :     return JS::ObjectValue(*obj);
     512             : }
     513             : 
     514           0 : CMessage* CMessageMinimapPing::FromJSVal(const ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val))
     515             : {
     516           0 :     return new CMessageMinimapPing();
     517             : }
     518             : 
     519             : ////////////////////////////////
     520             : 
     521           0 : JS::Value CMessageCinemaPathEnded::ToJSVal(const ScriptInterface& scriptInterface) const
     522             : {
     523           0 :     TOJSVAL_SETUP();
     524           0 :     SET_MSG_PROPERTY(name);
     525           0 :     return JS::ObjectValue(*obj);
     526             : }
     527             : 
     528           0 : CMessage* CMessageCinemaPathEnded::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
     529             : {
     530           0 :     FROMJSVAL_SETUP();
     531           0 :     GET_MSG_PROPERTY(CStrW, name);
     532           0 :     return new CMessageCinemaPathEnded(name);
     533             : }
     534             : 
     535             : ////////////////////////////////
     536             : 
     537           0 : JS::Value CMessageCinemaQueueEnded::ToJSVal(const ScriptInterface& scriptInterface) const
     538             : {
     539           0 :     TOJSVAL_SETUP();
     540           0 :     return JS::ObjectValue(*obj);
     541             : }
     542             : 
     543           0 : CMessage* CMessageCinemaQueueEnded::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
     544             : {
     545           0 :     FROMJSVAL_SETUP();
     546           0 :     return new CMessageCinemaQueueEnded();
     547             : }
     548             : 
     549             : ////////////////////////////////////////////////////////////////
     550             : 
     551           0 : JS::Value CMessagePlayerColorChanged::ToJSVal(const ScriptInterface& scriptInterface) const
     552             : {
     553           0 :     TOJSVAL_SETUP();
     554           0 :     SET_MSG_PROPERTY(player);
     555           0 :     return JS::ObjectValue(*obj);
     556             : }
     557             : 
     558           0 : CMessage* CMessagePlayerColorChanged::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
     559             : {
     560           0 :     FROMJSVAL_SETUP();
     561           0 :     GET_MSG_PROPERTY(player_id_t, player);
     562           0 :     return new CMessagePlayerColorChanged(player);
     563             : }
     564             : 
     565             : ////////////////////////////////////////////////////////////////
     566             : 
     567           3 : CMessage* CMessageFromJSVal(int mtid, const ScriptInterface& scriptingInterface, JS::HandleValue val)
     568             : {
     569           3 :     switch (mtid)
     570             :     {
     571             : #define MESSAGE(name) case MT_##name: return CMessage##name::FromJSVal(scriptingInterface, val);
     572             : #define INTERFACE(name)
     573             : #define COMPONENT(name)
     574             : #include "simulation2/TypeList.h"
     575             : #undef COMPONENT
     576             : #undef INTERFACE
     577             : #undef MESSAGE
     578             :     }
     579             : 
     580           0 :     return NULL;
     581             : }

Generated by: LCOV version 1.13