12 #include "../clib/cfgelem.h" 13 #include "../clib/cfgfile.h" 14 #include "../clib/clib.h" 15 #include "../clib/fileutil.h" 16 #include "../clib/logfacility.h" 17 #include "../clib/rawtypes.h" 18 #include "../clib/stlutil.h" 62 unsigned short tmp =
static_cast<unsigned short>( strtoul( str.c_str(),
nullptr, 0 ) );
66 return static_cast<UACTION>( tmp );
70 elem.
throw_error(
"Animation value of " + str +
" is out of range" );
83 while ( cf.
read( elem ) )
85 if ( elem.
type_is(
"OnMount" ) )
87 std::string from_str, to_str;
95 else if ( elem.
type_is(
"MobileType" ) )
98 std::string key, value;
106 auto split_str = [](
const std::string& source ) -> std::vector<std::string> {
109 std::vector<std::string> result;
114 if ( tmp.at( 0 ) ==
'#' )
116 result.push_back( tmp );
123 std::string entry(
"OldAnim" + std::to_string(
id ) );
124 if ( elem.
has_prop( entry.c_str() ) )
126 std::vector<std::string> values = split_str( elem.
remove_string( entry.c_str() ) );
127 if ( !values.empty() )
130 static_cast<u16>( strtoul( values[0].c_str(),
nullptr, 0 ) );
138 if ( values.size() > 1 )
140 static_cast<u16>( strtoul( values[1].c_str(),
nullptr, 0 ) );
141 if ( values.size() > 2 )
143 static_cast<u16>( strtoul( values[2].c_str(),
nullptr, 0 ) );
144 if ( values.size() > 3 )
146 static_cast<u8>( strtoul( values[3].c_str(),
nullptr, 0 ) );
147 if ( values.size() > 4 )
149 static_cast<u8>( strtoul( values[4].c_str(),
nullptr, 0 ) );
150 if ( values.size() > 5 )
152 static_cast<u8>( strtoul( values[5].c_str(),
nullptr, 0 ) );
154 entry =
"NewAnim" + std::to_string(
id );
155 if ( elem.
has_prop( entry.c_str() ) )
157 std::vector<std::string> values = split_str( elem.
remove_string( entry.c_str() ) );
158 if ( !values.empty() )
161 static_cast<u16>( strtoul( values[0].c_str(),
nullptr, 0 ) );
166 if ( values.size() > 1 )
168 static_cast<u16>( strtoul( values[1].c_str(),
nullptr, 0 ) );
169 if ( values.size() > 2 )
171 static_cast<u8>( strtoul( values[2].c_str(),
nullptr, 0 ) );
181 unsigned short framecount ,
182 unsigned short repeatcount ,
185 unsigned char delay )
193 oldanim.
valid =
true;
194 oldanim.
action =
static_cast<u16>( action );
197 oldanim.
backward =
static_cast<u8>( backward );
199 oldanim.
delay = delay;
206 if ( translates.second.has_graphic( obj->
graphic ) )
208 translate = &translates.second;
219 if ( new_action == 0 )
222 oldanim.
action =
static_cast<u16>( new_action );
225 if ( translate !=
nullptr )
227 oldanim = translate->
old_anim[action];
228 newanim = translate->
new_anim[action];
232 ERROR_PRINT <<
"Warning: undefined animXlate.cfg entry for graphic 0x" 233 << fmt::hexu( obj->
graphic ) <<
"\n";
238 static_cast<DIRECTION_FLAG_OLD>( oldanim.
backward ),
249 if ( stricmp( (
const char*)cmd->
data,
"bow" ) == 0 )
251 else if ( stricmp( (
const char*)cmd->
data,
"salute" ) == 0 )
void update(u16 anim, u16 action, u8 subaction, u16 action_old, u16 framecount_old, u16 repeat_old, Core::DIRECTION_FLAG_OLD backward_old, Core::REPEAT_FLAG_OLD repeat_flag_old, u8 delay_old, bool oldanim_valid, bool newanim_valid)
bool has_graphic(u16 graphic) const
bool remove_first_prop(std::string *propname, std::string *value)
std::string remove_string(const char *propname)
NewAnimDef new_anim[ACTION__HIGHEST+1]
std::vector< u16 > graphics
UACTION mount_action_xlate[ACTION__HIGHEST+1]
OldAnimDef old_anim[ACTION__HIGHEST+1]
const char * rest() const
POL_NORETURN void throw_error(const std::string &errmsg) const
std::map< std::string, MobileTranslate > animation_translates
void load_anim_xlate_cfg(bool)
static void InVisualRange(const UObject *obj, F &&f)
void handle_action(Network::Client *client, PKTIN_12 *cmd)
UACTION str_to_action(Clib::ConfigElem &elem, const std::string &str)
bool type_is(const char *name) const
bool has_prop(const char *propname) const
unsigned short remove_ushort(const char *propname)
int translate(const std::string &name, TRANSLATION *table)
virtual void Send(Client *client) POL_OVERRIDE
bool FileExists(const char *filename)
bool read(ConfigElem &elem)
bool UACTION_IS_VALID(unsigned short action)
bool remove_bool(const char *propname)
void send_action_to_inrange(const Mobile::Character *obj, UACTION action, unsigned short framecount=0x05, unsigned short repeatcount=0x01, DIRECTION_FLAG_OLD backward=FORWARD, REPEAT_FLAG_OLD repeatflag=NOREPEAT, unsigned char delay=0x01)
size_t estimateSize() const