I will still talk with vector as base, you can sort the damage with vector easy, you can look up function mob_add_spawn with it code sorting the qty of mob spawn in a map
// sort spawns by spawn quantity
std::sort(spawns.begin(), spawns.end(),
[](const spawn_info & a, const spawn_info & b) -> bool
{ return a.qty > b.qty; });
quoted from here https://www.geeksforgeeks.org/vector-in-cpp-stl/
Vectors are the same as dynamic arrays with the ability to resize itself automatically when an element is inserted or deleted
so you don't need to pre defined number to set size on the container.
for mvp its reset upon dead, so if mvp has rebirth skill, it will reset the logs value. later on will be removed in memory in status.cpp
if(flag&4) // Delete from memory. (also invokes map removal code)
unit_free(target,CLR_DEAD);
else if(flag&2) // remove from map
unit_remove_map(target,CLR_DEAD);
so you can still get the data of damage log, before it was wiped out from memory, but no longer after. so in case you want to preserve the damage log, you need to save it on sql db
its not complicated, you just need consider what you want to log, I think it will be gid of mob, account id, char id, damage
CREATE TABLE IF NOT EXISTS `mob_damage_log` (
`id` int(11) NOT NULL auto_increment,
`mob_gid` int(11) NOT NULL default '0',
`account_id` int(11) NOT NULL default '0',
`char_id` int(11) NOT NULL default '0',
`damage` int(10) NOT NULL default '0',
PRIMARY KEY (`id`),
KEY `mob_gid` (`mob_gid`),
KEY `account_id` (`account_id`),
KEY `char_id` (`char_id`)
) ENGINE=MyISAM;
something like that maybe. and the code would go like this, as the sd, you can get it with map_session_data *sd= map_charid2sd(char_id);
if( SQL_ERROR == Sql_Query(
mmysql_handle,
"INSERT INTO `mob_damage_log`(`mob_gid`,`account_id`,`char_id`,`damage`) VALUES ( '%d', '%d', '%d', '%d' )",
md->bl.id, sd->status.account_id, sd->status.account_id, damage) ){
Sql_ShowDebug(mmysql_handle);
return;
}