1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program 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 Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #include "client_cfg.h"
27 #include "ingame_database_manager.h"
28 #include "user_entity.h"
29 #include "time_client.h"
30 #include "net_manager.h"
32 #include "nel/misc/sheet_id.h"
38 using namespace NLMISC
;
46 H_AUTO_DECL ( RZ_Client_Update_Demo
)
51 //-----------------------------------------------
53 // Call a function for a demo to init.
54 //-----------------------------------------------
57 for(uint i
= 0; i
<ClientCfg
.StartCommands
.size()/7; ++i
)
63 CLFECOMMON::TCLEntityId entitySlot
= i
+1;
65 // Try to create the sheet with the parameter as a string.
67 if(!sheetId
.buildSheetId(ClientCfg
.StartCommands
[i
*7]))
69 nlwarning("initDemo: cannot create the entity %d '%s'.", i
*7, ClientCfg
.StartCommands
[i
*7].c_str());
73 // Remove the old entity.
74 EntitiesMngr
.remove(entitySlot
, false);
76 // Create the new entity.
77 TNewEntityInfo emptyEntityInfo
;
78 emptyEntityInfo
.reset();
79 CEntityCL
*entity
= EntitiesMngr
.create(entitySlot
, sheetId
.asInt(), emptyEntityInfo
);
82 double xTmp
, yTmp
, zTmp
;
83 fromString(ClientCfg
.StartCommands
[i
*7+1], xTmp
);
84 fromString(ClientCfg
.StartCommands
[i
*7+2], yTmp
);
85 fromString(ClientCfg
.StartCommands
[i
*7+3], zTmp
);
87 // Compute the position (FIRST POS AFTER CREATE IS THE START POSITION).
88 sint64 x
= (sint64
)(xTmp
*1000.0);
89 sint64 y
= (sint64
)(yTmp
*1000.0);
90 sint64 z
= (sint64
)(zTmp
*1000.0);
92 // Write the position in the DB.
93 IngameDbMngr
.setProp("Entities:E" + toString(entitySlot
) + ":P0", x
);
94 IngameDbMngr
.setProp("Entities:E" + toString(entitySlot
) + ":P1", y
);
95 IngameDbMngr
.setProp("Entities:E" + toString(entitySlot
) + ":P2", z
);
97 // Update the position.
98 uint gameCycle
= NetMngr
.getCurrentClientTick();
99 uint prop
= 0; // 0: Position ; 3: orientation ; 4: mode ; 5: behaviour ; 6: nameId ; 7: target ; 8: visual1 ; 9: visual2
100 EntitiesMngr
.updateVisualProperty(gameCycle
, entitySlot
, prop
);
103 float xTmp2
, yTmp2
, zTmp2
;
104 fromString(ClientCfg
.StartCommands
[i
*7+4], xTmp2
);
105 fromString(ClientCfg
.StartCommands
[i
*7+5], yTmp2
);
106 fromString(ClientCfg
.StartCommands
[i
*7+6], zTmp2
);
107 entity
->front(CVector(xTmp2
, yTmp2
, zTmp2
));
108 entity
->dir(UserEntity
->front());
114 gameCycle = NetMngr.getCurrentClientTick()+100; // 10sec later.
115 x = (sint64)((entity->pos().x+UserEntity->front().x*50.0)*1000.0);
116 y = (sint64)((entity->pos().y+UserEntity->front().y*50.0)*1000.0);
117 z = (sint64)((entity->pos().z+UserEntity->front().z*50.0)*1000.0);
118 // Write the position in the DB.
119 IngameDbMngr.setProp("Entities:E" + toString(entitySlot) + ":P0", x);
120 IngameDbMngr.setProp("Entities:E" + toString(entitySlot) + ":P1", y);
121 IngameDbMngr.setProp("Entities:E" + toString(entitySlot) + ":P2", z);
122 // Update the position.
123 EntitiesMngr.updateVisualProperty(gameCycle, entitySlot, prop);
127 nldebug("initDemo: entity(%s) in slot %d cannot be created.", sheetId
.toString().c_str(), entitySlot
);
131 //-----------------------------------------------
133 // Call a function for a demo to update.
134 //-----------------------------------------------
135 void updateDemo(double /* timeElapsed */)
137 H_AUTO_USE ( RZ_Client_Update_Demo
)