4144
-
Content Count
1189 -
Joined
-
Last visited
-
Days Won
124
Single Status Update
-
hi, good night, how are you?
I'm trying to bring the swap item system to my hercules emulator and then launch it here in the community, I was successful, I'm just having a problem that according to the rathena commit they use the namespace std::map and std::pair that are C ++ languages not supported by hercules, how can I do this via struct or some function in C ?? Follow the link, if you can help I am grateful.
https://github.com/rathena/rathena/pull/3548/commits/2a733e04268970fd5e42e23697cf944f14449119
PC.C
int pc_equipswitch( struct map_session_data* sd, int index ) {
// Get the target equip mask
int position = sd->inventory.u.items_inventory[index].equipSwitch;
// Get the currently equipped item
short equippedItem = pc_checkequip( sd, position );
// No item equipped at the target
if( equippedItem == -1 ) {
// Remove it from the equip switch
pc_equipswitch_remove( sd, index );
pc_equipitem( sd, index, position );
return position;
}else{
std::map<int, int> unequipped;
int unequipped_position = 0;
for( int i = 0; i < EQI_MAX; i++ ) {
int unequip_index = sd->equip_index;
if( unequip_index >= 0 && position & equip_bitmask ) {
struct item* unequip_item = &sd->inventory.u.items_inventory[unequip_index];
// Store the unequipped index and position mask for later
unequipped[unequip_index] = unequip_item->equip;
// Keep the position for later
unequipped_position |= unequip_item->equip;
// Unequip the item
pc_unequipitem( sd, unequip_index, 0 );
}
}
int all_position = position | unequipped_position;
// Equip everything that is hit by the mask
for( int i = 0; i < EQI_MAX; i++ ){
int exchange_index = sd->equip_switch_index;
if( exchange_index >= 0 && all_position & equip_bitmask ){
struct item* exchange_item = &sd->inventory.u.items_inventory[exchange_index];
// Store the target position
int exchange_position = exchange_item->equipSwitch;
// Remove the item from equip switch
pc_equipswitch_remove( sd, exchange_index );
// Equip the item at the destinated position
pc_equipitem( sd, exchange_index, exchange_position );
}
}
// Place all unequipped items into the equip switch window
for( std::pair<int, int> pair : unequipped ){
int unequipped_index = pair.first;
int unequipped_position = pair.second;
// Rebuild the index cache
for( int i = 0; i < EQI_MAX; i++ ){
if( unequipped_position & equip_bitmask ){
sd->equip_switch_index = unequipped_index;
}
}
// Set the correct position mask
sd->inventory.u.items_inventory[unequipped_index].equipSwitch = unequipped_position;
// Notify the client
clif_equipswitch_add( sd, unequipped_index, unequipped_position, false );
}
return all_position;
}
}