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/>.
22 #include "nel/misc/types_nl.h"
23 #include "ai_share/ai_types.h"
26 void selectEntities (const string
&entityName
, vector
<uint32
> &entities
)
28 if (entityName
.empty ())
41 - <8 digit hex mgr CAIEntityId>
49 - <8 digit hex grp CAIEntityId>
50 - <mgr id>:<grp index>
58 - <8 digit hex bot CAIEntityId>
59 - <grp id>:<bot index>
66 uint32 entity
= atoi (entityName
.c_str());
68 if (entityName
== "*")
70 // we want all entities
71 for (uint i
= 0; i
< Entities
.size(); i
++)
72 entities
.push_back (i
);
74 else if (entityName
.find ("-") != string::npos
)
78 NLMISC::fromString(entityName
.substr(entityName
.find("-")+1), ent2
);
79 for (uint i
= entity
; i
<= ent2
; i
++)
80 entities
.push_back (i
);
84 // we want a specific entity
85 entities
.push_back (entity
);
91 #define ENTITY_VARIABLE(__name,__help) \
92 struct __name##Class : public NLMISC::ICommand \
94 __name##Class () : NLMISC::ICommand(#__name, __help, "<entity>
95 [<value>]") { Type = Variable; } \
96 virtual bool execute(const std::vector<std::string> &args,
99 if (args
.size () != 1 && args
.size () != 2) \
102 vector
<uint32
> entities
; \
103 selectEntities (args
[0], entities
); \
105 for (uint i
= 0; i
< entities
.size(); i
++) \
108 if (args
.size()==2) \
112 pointer (entities
[i
], (args
.size()==1), value
); \
113 log
.displayNL ("Entity %d Variable %s = %s", entities
[i
], _CommandName
.c_str(), value
.c_str()); \
117 void pointer(uint32 entity
, bool get
, std::string
&value
); \
119 __name
##Class __name##Instance; \
120 void __name##Class::pointer(uint32 entity, bool get, std::string &value)
122 ENTITY_VARIABLE(test
, "test")
126 // get the value if available
127 if(entity
< Entities
.size())
128 value
= toString(Entities
[entity
].first
);
132 // set the variable with the new value
133 if(entity
>= Entities
.size())
134 Entities
.resize(entity
+1);
136 NLMISC::fromString(value
, Entities
[entity
].first
);
140 ENTITY_VARIABLE(test2
, "test2")
144 // get the value if available
145 if(entity
< Entities
.size())
146 value
= toString(Entities
[entity
].second
);
150 // set the variable with the new value
151 if(entity
>= Entities
.size())
152 Entities
.resize(entity
+1);
154 NLMISC::fromString(value
, Entities
[entity
].second
);