Browse Source

Add other player in mail transactions (#7568)

* Add other player's char_id in mail transactions

Thanks to @tokeiburu

Co-authored-by: Lemongrass3110 <lemongrass@kstp.at>
Vincent Stumpf 2 years ago
parent
commit
7dd6eb5182

+ 2 - 2
src/map/atcommand.cpp

@@ -2804,12 +2804,12 @@ ACMD_FUNC(zeny)
 	}
 	}
 
 
 	if(zeny > 0){
 	if(zeny > 0){
-	    if((ret=pc_getzeny(sd,zeny,LOG_TYPE_COMMAND,NULL)) == 1)
+	    if((ret=pc_getzeny(sd,zeny,LOG_TYPE_COMMAND)) == 1)
 		clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
 		clif_displaymessage(fd, msg_txt(sd,149)); // Unable to increase the number/value.
 	}
 	}
 	else {
 	else {
 	    if( sd->status.zeny < -zeny ) zeny = -sd->status.zeny;
 	    if( sd->status.zeny < -zeny ) zeny = -sd->status.zeny;
-	    if((ret=pc_payzeny(sd,-zeny,LOG_TYPE_COMMAND,NULL)) == 1)
+	    if((ret=pc_payzeny(sd,-zeny,LOG_TYPE_COMMAND)) == 1)
 		clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
 		clif_displaymessage(fd, msg_txt(sd,41)); // Unable to decrease the number/value.
 	}
 	}
 	if(!ret) clif_displaymessage(fd, msg_txt(sd,176)); //ret=0 mean cmd success
 	if(!ret) clif_displaymessage(fd, msg_txt(sd,176)); //ret=0 mean cmd success

+ 1 - 1
src/map/battle.cpp

@@ -8318,7 +8318,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
 			if (sd) {
 			if (sd) {
 				if (md.damage > sd->status.zeny)
 				if (md.damage > sd->status.zeny)
 					md.damage = sd->status.zeny;
 					md.damage = sd->status.zeny;
-				pc_payzeny(sd,(int)cap_value(md.damage, INT_MIN, INT_MAX),LOG_TYPE_STEAL,NULL);
+				pc_payzeny(sd,(int)cap_value(md.damage, INT_MIN, INT_MAX),LOG_TYPE_STEAL);
 			}
 			}
 			break;
 			break;
 	}
 	}

+ 2 - 2
src/map/buyingstore.cpp

@@ -462,8 +462,8 @@ void buyingstore_trade( map_session_data* sd, uint32 account_id, unsigned int bu
 		}
 		}
 
 
 		// pay up
 		// pay up
-		pc_payzeny(pl_sd, zeny, LOG_TYPE_BUYING_STORE, sd);
-		pc_getzeny(sd, zeny, LOG_TYPE_BUYING_STORE, pl_sd);
+		pc_payzeny(pl_sd, zeny, LOG_TYPE_BUYING_STORE, sd->status.char_id);
+		pc_getzeny(sd, zeny, LOG_TYPE_BUYING_STORE, pl_sd->status.char_id);
 		pl_sd->buyingstore.zenylimit-= zeny;
 		pl_sd->buyingstore.zenylimit-= zeny;
 
 
 		// notify clients
 		// notify clients

+ 10 - 10
src/map/clif.cpp

@@ -3429,7 +3429,7 @@ void clif_parse_guild_castle_teleport_request(int fd, map_session_data* sd){
 			break;
 			break;
 	}
 	}
 
 
-	if (zeny && pc_payzeny(sd, zeny, LOG_TYPE_OTHER, nullptr)) {
+	if (zeny && pc_payzeny(sd, zeny, LOG_TYPE_OTHER)) {
 		clif_guild_castle_teleport_res(*sd, SIEGE_TP_NOT_ENOUGH_ZENY);
 		clif_guild_castle_teleport_res(*sd, SIEGE_TP_NOT_ENOUGH_ZENY);
 		return;
 		return;
 	}
 	}
@@ -17009,7 +17009,7 @@ void clif_parse_Auction_register(int fd, map_session_data *sd)
 		pc_delitem(sd, sd->auction.index, sd->auction.amount, 1, 6, LOG_TYPE_AUCTION);
 		pc_delitem(sd, sd->auction.index, sd->auction.amount, 1, 6, LOG_TYPE_AUCTION);
 		sd->auction.amount = 0;
 		sd->auction.amount = 0;
 
 
-		pc_payzeny(sd, zeny, LOG_TYPE_AUCTION, NULL);
+		pc_payzeny(sd, zeny, LOG_TYPE_AUCTION);
 	}
 	}
 }
 }
 
 
@@ -17049,7 +17049,7 @@ void clif_parse_Auction_bid(int fd, map_session_data *sd){
 	else if ( CheckForCharServer() ) // char server is down (bugreport:1138)
 	else if ( CheckForCharServer() ) // char server is down (bugreport:1138)
 		clif_Auction_message(fd, 0); // You have failed to bid into the auction
 		clif_Auction_message(fd, 0); // You have failed to bid into the auction
 	else {
 	else {
-		pc_payzeny(sd, bid, LOG_TYPE_AUCTION, NULL);
+		pc_payzeny(sd, bid, LOG_TYPE_AUCTION);
 		intif_Auction_bid(sd->status.char_id, sd->status.name, auction_id, bid);
 		intif_Auction_bid(sd->status.char_id, sd->status.name, auction_id, bid);
 	}
 	}
 }
 }
@@ -22416,7 +22416,7 @@ void clif_parse_refineui_refine( int fd, map_session_data* sd ){
 	}
 	}
 
 
 	// Try to pay for the refine
 	// Try to pay for the refine
-	if( pc_payzeny( sd, cost->zeny, LOG_TYPE_CONSUME, NULL ) ){
+	if( pc_payzeny( sd, cost->zeny, LOG_TYPE_CONSUME ) ){
 		clif_npc_buy_result( sd, e_purchase_result::PURCHASE_FAIL_MONEY ); // "You do not have enough zeny."
 		clif_npc_buy_result( sd, e_purchase_result::PURCHASE_FAIL_MONEY ); // "You do not have enough zeny."
 		return;
 		return;
 	}
 	}
@@ -22580,7 +22580,7 @@ bool clif_parse_stylist_buy_sub( map_session_data* sd, _look look, int16 index )
 		return false;
 		return false;
 	}
 	}
 
 
-	if( costs->price > 0 && pc_payzeny( sd, costs->price, LOG_TYPE_OTHER, nullptr ) != 0 ){
+	if( costs->price > 0 && pc_payzeny( sd, costs->price, LOG_TYPE_OTHER ) != 0 ){
 		return false;
 		return false;
 	}
 	}
 
 
@@ -23834,7 +23834,7 @@ void clif_parse_enchantgrade_start( int fd, map_session_data* sd ){
 		}
 		}
 	}
 	}
 
 
-	if( pc_payzeny( sd, option->zeny, LOG_TYPE_ENCHANTGRADE, nullptr ) > 0 ){
+	if( pc_payzeny( sd, option->zeny, LOG_TYPE_ENCHANTGRADE ) > 0 ){
 		return;
 		return;
 	}
 	}
 
 
@@ -24280,7 +24280,7 @@ void clif_parse_enchantwindow_general( int fd, map_session_data* sd ){
 		materials[idx] = entry.second;
 		materials[idx] = entry.second;
 	}
 	}
 
 
-	if( pc_payzeny( sd, enchant_slot->normal.zeny, LOG_TYPE_ENCHANT, nullptr ) != 0 ){
+	if( pc_payzeny( sd, enchant_slot->normal.zeny, LOG_TYPE_ENCHANT ) != 0 ){
 		return;
 		return;
 	}
 	}
 
 
@@ -24407,7 +24407,7 @@ void clif_parse_enchantwindow_perfect( int fd, map_session_data* sd ){
 		materials[idx] = entry.second;
 		materials[idx] = entry.second;
 	}
 	}
 
 
-	if( pc_payzeny( sd, perfect_enchant->zeny, LOG_TYPE_ENCHANT, nullptr ) != 0 ){
+	if( pc_payzeny( sd, perfect_enchant->zeny, LOG_TYPE_ENCHANT ) != 0 ){
 		return;
 		return;
 	}
 	}
 
 
@@ -24504,7 +24504,7 @@ void clif_parse_enchantwindow_upgrade( int fd, map_session_data* sd ){
 		materials[idx] = entry.second;
 		materials[idx] = entry.second;
 	}
 	}
 
 
-	if( pc_payzeny( sd, upgrade->zeny, LOG_TYPE_ENCHANT, nullptr ) != 0 ){
+	if( pc_payzeny( sd, upgrade->zeny, LOG_TYPE_ENCHANT ) != 0 ){
 		return;
 		return;
 	}
 	}
 
 
@@ -24609,7 +24609,7 @@ void clif_parse_enchantwindow_reset( int fd, map_session_data* sd ){
 		materials[idx] = entry.second;
 		materials[idx] = entry.second;
 	}
 	}
 
 
-	if( pc_payzeny( sd, enchant->reset.zeny, LOG_TYPE_ENCHANT, nullptr ) != 0 ){
+	if( pc_payzeny( sd, enchant->reset.zeny, LOG_TYPE_ENCHANT ) != 0 ){
 		return;
 		return;
 	}
 	}
 
 

+ 5 - 2
src/map/intif.cpp

@@ -2657,6 +2657,7 @@ static void intif_parse_Mail_receiver( int fd ){
 	// Only f the player is online
 	// Only f the player is online
 	if( sd ){
 	if( sd ){
 		clif_Mail_Receiver_Ack( sd, RFIFOL( fd, 6 ), RFIFOW( fd, 10 ), RFIFOW( fd, 12 ), RFIFOCP( fd, 14 ) );
 		clif_Mail_Receiver_Ack( sd, RFIFOL( fd, 6 ), RFIFOW( fd, 10 ), RFIFOW( fd, 12 ), RFIFOCP( fd, 14 ) );
+		sd->mail.dest_id = RFIFOL(fd, 6);
 	}
 	}
 }
 }
 
 
@@ -2664,10 +2665,12 @@ bool intif_mail_checkreceiver( map_session_data* sd, char* name ){
 	map_session_data *tsd;
 	map_session_data *tsd;
 
 
 	tsd = map_nick2sd( name, false );
 	tsd = map_nick2sd( name, false );
+	sd->mail.dest_id = 0;
 
 
 	// If the target player is online on this map-server
 	// If the target player is online on this map-server
 	if( tsd != NULL ){
 	if( tsd != NULL ){
 		clif_Mail_Receiver_Ack( sd, tsd->status.char_id, tsd->status.class_, tsd->status.base_level, name );
 		clif_Mail_Receiver_Ack( sd, tsd->status.char_id, tsd->status.class_, tsd->status.base_level, name );
+		sd->mail.dest_id = tsd->status.char_id;
 		return true;
 		return true;
 	}
 	}
 
 
@@ -2787,7 +2790,7 @@ static void intif_parse_Auction_register(int fd)
 		clif_Auction_message(sd->fd, 4);
 		clif_Auction_message(sd->fd, 4);
 		pc_additem(sd, &auction.item, auction.item.amount, LOG_TYPE_AUCTION);
 		pc_additem(sd, &auction.item, auction.item.amount, LOG_TYPE_AUCTION);
 
 
-		pc_getzeny(sd, zeny, LOG_TYPE_AUCTION, NULL);
+		pc_getzeny(sd, zeny, LOG_TYPE_AUCTION);
 	}
 	}
 }
 }
 
 
@@ -2917,7 +2920,7 @@ static void intif_parse_Auction_bid(int fd)
 	clif_Auction_message(sd->fd, result);
 	clif_Auction_message(sd->fd, result);
 	if( bid > 0 )
 	if( bid > 0 )
 	{
 	{
-		pc_getzeny(sd, bid, LOG_TYPE_AUCTION,NULL);
+		pc_getzeny(sd, bid, LOG_TYPE_AUCTION);
 	}
 	}
 	if( result == 1 )
 	if( result == 1 )
 	{ // To update the list, display your buy list
 	{ // To update the list, display your buy list

+ 5 - 6
src/map/log.cpp

@@ -278,17 +278,16 @@ void log_pick_mob(struct mob_data* md, e_log_pick_type type, int amount, struct
 }
 }
 
 
 /// logs zeny transactions
 /// logs zeny transactions
-void log_zeny(map_session_data* sd, e_log_pick_type type, map_session_data* src_sd, int amount)
+// ids are char_ids
+void log_zeny(const map_session_data &target_sd, e_log_pick_type type, uint32 src_id, int amount)
 {
 {
-	nullpo_retv(sd);
-
 	if( !log_config.zeny || ( log_config.zeny != 1 && abs(amount) < log_config.zeny ) )
 	if( !log_config.zeny || ( log_config.zeny != 1 && abs(amount) < log_config.zeny ) )
 		return;
 		return;
 
 
 	if( log_config.sql_logs )
 	if( log_config.sql_logs )
 	{
 	{
-		if( SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `src_id`, `type`, `amount`, `map`) VALUES (NOW(), '%d', '%d', '%c', '%d', '%s')",
-			log_config.log_zeny, sd->status.char_id, src_sd->status.char_id, log_picktype2char(type), amount, mapindex_id2name(sd->mapindex)) )
+		if (SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `src_id`, `type`, `amount`, `map`) VALUES (NOW(), '%d', '%d', '%c', '%d', '%s')",
+			log_config.log_zeny, target_sd.status.char_id, src_id, log_picktype2char(type), amount, mapindex_id2name(target_sd.mapindex)))
 		{
 		{
 			Sql_ShowDebug(logmysql_handle);
 			Sql_ShowDebug(logmysql_handle);
 			return;
 			return;
@@ -304,7 +303,7 @@ void log_zeny(map_session_data* sd, e_log_pick_type type, map_session_data* src_
 			return;
 			return;
 		time(&curtime);
 		time(&curtime);
 		strftime(timestring, sizeof(timestring), log_timestamp_format, localtime(&curtime));
 		strftime(timestring, sizeof(timestring), log_timestamp_format, localtime(&curtime));
-		fprintf(logfp, "%s - %s[%d]\t%s[%d]\t%d\t\n", timestring, src_sd->status.name, src_sd->status.account_id, sd->status.name, sd->status.account_id, amount);
+		fprintf(logfp, "%s - [%d] ->\t%s[%d]\t%d\t\n", timestring, src_id, target_sd.status.name, target_sd.status.char_id, amount);
 		fclose(logfp);
 		fclose(logfp);
 	}
 	}
 }
 }

+ 1 - 1
src/map/log.hpp

@@ -78,7 +78,7 @@ enum e_log_feeding_type : uint8
 /// new logs
 /// new logs
 void log_pick_pc(map_session_data* sd, e_log_pick_type type, int amount, struct item* itm);
 void log_pick_pc(map_session_data* sd, e_log_pick_type type, int amount, struct item* itm);
 void log_pick_mob(struct mob_data* md, e_log_pick_type type, int amount, struct item* itm);
 void log_pick_mob(struct mob_data* md, e_log_pick_type type, int amount, struct item* itm);
-void log_zeny(map_session_data* sd, e_log_pick_type type, map_session_data* src_sd, int amount);
+void log_zeny(const map_session_data &target_sd, e_log_pick_type type, uint32 src_id, int amount);
 void log_cash( map_session_data* sd, e_log_pick_type type, e_log_cash_type cash_type, int amount );
 void log_cash( map_session_data* sd, e_log_pick_type type, e_log_cash_type cash_type, int amount );
 void log_npc( struct npc_data* nd, const char* message );
 void log_npc( struct npc_data* nd, const char* message );
 void log_npc(map_session_data* sd, const char *message);
 void log_npc(map_session_data* sd, const char *message);

+ 6 - 4
src/map/mail.cpp

@@ -28,6 +28,7 @@ void mail_clear(map_session_data *sd)
 		sd->mail.item[i].amount = 0;
 		sd->mail.item[i].amount = 0;
 	}
 	}
 	sd->mail.zeny = 0;
 	sd->mail.zeny = 0;
+	sd->mail.dest_id = 0;
 
 
 	return;
 	return;
 }
 }
@@ -53,7 +54,7 @@ int mail_removeitem(map_session_data *sd, short flag, int idx, int amount)
 
 
 	if( flag ){
 	if( flag ){
 		if( battle_config.mail_attachment_price > 0 ){
 		if( battle_config.mail_attachment_price > 0 ){
-			if( pc_payzeny( sd, battle_config.mail_attachment_price, LOG_TYPE_MAIL, NULL ) ){
+			if( pc_payzeny( sd, battle_config.mail_attachment_price, LOG_TYPE_MAIL ) ){
 				return false;
 				return false;
 			}
 			}
 		}
 		}
@@ -105,7 +106,8 @@ bool mail_removezeny( map_session_data *sd, bool flag ){
 	if( sd->mail.zeny > 0 ){
 	if( sd->mail.zeny > 0 ){
 		//Zeny send
 		//Zeny send
 		if( flag ){
 		if( flag ){
-			if( pc_payzeny( sd, sd->mail.zeny + sd->mail.zeny * battle_config.mail_zeny_fee / 100, LOG_TYPE_MAIL, NULL ) ){
+			// It's possible that we don't know what the dest_id is, so it will be 0
+			if (pc_payzeny(sd, sd->mail.zeny + sd->mail.zeny * battle_config.mail_zeny_fee / 100, LOG_TYPE_MAIL, sd->mail.dest_id)) {
 				return false;
 				return false;
 			}
 			}
 		}else{
 		}else{
@@ -355,7 +357,7 @@ void mail_getattachment(map_session_data* sd, struct mail_message* msg, int zeny
 		sd->mail.pending_zeny -= zeny;
 		sd->mail.pending_zeny -= zeny;
 
 
 		// Add the zeny
 		// Add the zeny
-		pc_getzeny(sd, zeny,LOG_TYPE_MAIL, NULL);
+		pc_getzeny(sd, zeny, LOG_TYPE_MAIL, msg->send_id);
 		clif_mail_getattachment( sd, msg, 0, MAIL_ATT_ZENY );
 		clif_mail_getattachment( sd, msg, 0, MAIL_ATT_ZENY );
 	}
 	}
 }
 }
@@ -387,7 +389,7 @@ void mail_deliveryfail(map_session_data *sd, struct mail_message *msg){
 	}
 	}
 
 
 	if( msg->zeny > 0 ){
 	if( msg->zeny > 0 ){
-		pc_getzeny(sd,msg->zeny + msg->zeny*battle_config.mail_zeny_fee/100 + zeny,LOG_TYPE_MAIL, NULL); //Zeny receive (due to failure)
+		pc_getzeny(sd,msg->zeny + msg->zeny*battle_config.mail_zeny_fee/100 + zeny,LOG_TYPE_MAIL); //Zeny receive (due to failure)
 	}
 	}
 
 
 	clif_Mail_send(sd, WRITE_MAIL_FAILED);
 	clif_Mail_send(sd, WRITE_MAIL_FAILED);

+ 2 - 2
src/map/mob.cpp

@@ -2767,7 +2767,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
 					}
 					}
 				}
 				}
 				if(zeny) // zeny from mobs [Valaris]
 				if(zeny) // zeny from mobs [Valaris]
-					pc_getzeny(tmpsd[i], zeny, LOG_TYPE_PICKDROP_MONSTER, NULL);
+					pc_getzeny(tmpsd[i], zeny, LOG_TYPE_PICKDROP_MONSTER);
 			}
 			}
 
 
 			if( md->get_bosstype() == BOSSTYPE_MVP )
 			if( md->get_bosstype() == BOSSTYPE_MVP )
@@ -2878,7 +2878,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
 			if( sd->bonus.get_zeny_num && rnd()%100 < sd->bonus.get_zeny_rate ) {
 			if( sd->bonus.get_zeny_num && rnd()%100 < sd->bonus.get_zeny_rate ) {
 				i = sd->bonus.get_zeny_num > 0 ? sd->bonus.get_zeny_num : -md->level * sd->bonus.get_zeny_num;
 				i = sd->bonus.get_zeny_num > 0 ? sd->bonus.get_zeny_num : -md->level * sd->bonus.get_zeny_num;
 				if (!i) i = 1;
 				if (!i) i = 1;
-				pc_getzeny(sd, 1+rnd()%i, LOG_TYPE_PICKDROP_MONSTER, NULL);
+				pc_getzeny(sd, 1+rnd()%i, LOG_TYPE_PICKDROP_MONSTER);
 			}
 			}
 		}
 		}
 
 

+ 3 - 3
src/map/npc.cpp

@@ -2854,7 +2854,7 @@ e_purchase_result npc_buylist( map_session_data* sd, std::vector<s_npc_buy_list>
 	if( pc_inventoryblank(sd) < new_ )
 	if( pc_inventoryblank(sd) < new_ )
 		return e_purchase_result::PURCHASE_FAIL_COUNT;	// Not enough space to store items
 		return e_purchase_result::PURCHASE_FAIL_COUNT;	// Not enough space to store items
 
 
-	pc_payzeny(sd, (int)z, LOG_TYPE_NPC, NULL);
+	pc_payzeny(sd, (int)z, LOG_TYPE_NPC);
 
 
 	for( int i = 0; i < item_list.size(); ++i ) {
 	for( int i = 0; i < item_list.size(); ++i ) {
 		t_itemid nameid = item_list[i].nameid;
 		t_itemid nameid = item_list[i].nameid;
@@ -3082,7 +3082,7 @@ uint8 npc_selllist(map_session_data* sd, int list_length, PACKET_CZ_PC_SELL_ITEM
 	if( z > MAX_ZENY )
 	if( z > MAX_ZENY )
 		z = MAX_ZENY;
 		z = MAX_ZENY;
 
 
-	pc_getzeny(sd, (int)z, LOG_TYPE_NPC, NULL);
+	pc_getzeny(sd, (int)z, LOG_TYPE_NPC);
 
 
 	// custom merchant shop exp bonus
 	// custom merchant shop exp bonus
 	if( battle_config.shop_exp > 0 && z > 0 && ( skill = pc_checkskill(sd,MC_OVERCHARGE) ) > 0)
 	if( battle_config.shop_exp > 0 && z > 0 && ( skill = pc_checkskill(sd,MC_OVERCHARGE) ) > 0)
@@ -3315,7 +3315,7 @@ e_purchase_result npc_barter_purchase( map_session_data& sd, std::shared_ptr<s_n
 		}
 		}
 	}
 	}
 
 
-	if( pc_payzeny( &sd, (int)requiredZeny, LOG_TYPE_BARTER, nullptr ) != 0 ){
+	if( pc_payzeny( &sd, (int)requiredZeny, LOG_TYPE_BARTER ) != 0 ){
 		return e_purchase_result::PURCHASE_FAIL_MONEY;
 		return e_purchase_result::PURCHASE_FAIL_MONEY;
 	}
 	}
 
 

+ 1 - 1
src/map/party.cpp

@@ -1232,7 +1232,7 @@ void party_exp_share(struct party_data* p, struct block_list* src, t_exp base_ex
 #endif
 #endif
 
 
 		if (zeny) // zeny from mobs [Valaris]
 		if (zeny) // zeny from mobs [Valaris]
-			pc_getzeny(sd[i],zeny,LOG_TYPE_PICKDROP_MONSTER,NULL);
+			pc_getzeny(sd[i],zeny,LOG_TYPE_PICKDROP_MONSTER);
 	}
 	}
 }
 }
 
 

+ 12 - 14
src/map/pc.cpp

@@ -5572,10 +5572,10 @@ uint8 pc_inventoryblank(map_session_data *sd)
  * @param sd: Player
  * @param sd: Player
  * @param zeny: Zeny removed
  * @param zeny: Zeny removed
  * @param type: Log type
  * @param type: Log type
- * @param tsd: (optional) From who to log (if null take sd)
+ * @param log_charid: (optional) From who to log (if not needed, use 0)
  * @return 0: Success, 1: Failed (Removing negative Zeny or not enough Zeny), 2: Player not found
  * @return 0: Success, 1: Failed (Removing negative Zeny or not enough Zeny), 2: Player not found
  */
  */
-char pc_payzeny(map_session_data *sd, int zeny, enum e_log_pick_type type, map_session_data *tsd)
+char pc_payzeny(map_session_data *sd, int zeny, enum e_log_pick_type type, uint32 log_charid)
 {
 {
 	nullpo_retr(2,sd);
 	nullpo_retr(2,sd);
 
 
@@ -5592,8 +5592,7 @@ char pc_payzeny(map_session_data *sd, int zeny, enum e_log_pick_type type, map_s
 	sd->status.zeny -= zeny;
 	sd->status.zeny -= zeny;
 	clif_updatestatus(sd,SP_ZENY);
 	clif_updatestatus(sd,SP_ZENY);
 
 
-	if(!tsd) tsd = sd;
-	log_zeny(sd, type, tsd, -zeny);
+	log_zeny(*sd, type, log_charid, -zeny);
 	if( zeny > 0 && sd->state.showzeny ) {
 	if( zeny > 0 && sd->state.showzeny ) {
 		char output[255];
 		char output[255];
 		sprintf(output, "Removed %dz.", zeny);
 		sprintf(output, "Removed %dz.", zeny);
@@ -5607,10 +5606,10 @@ char pc_payzeny(map_session_data *sd, int zeny, enum e_log_pick_type type, map_s
  * Attempts to give zeny to player
  * Attempts to give zeny to player
  * @param sd: Player
  * @param sd: Player
  * @param type: Log type
  * @param type: Log type
- * @param tsd: (optional) From who to log (if null take sd)
+ * @param log_charid: (optional) From who to log (if not needed, use 0)
  * @return -1: Player not found, 0: Success, 1: Giving negative Zeny
  * @return -1: Player not found, 0: Success, 1: Giving negative Zeny
  */
  */
-char pc_getzeny(map_session_data *sd, int zeny, enum e_log_pick_type type, map_session_data *tsd)
+char pc_getzeny(map_session_data *sd, int zeny, enum e_log_pick_type type, uint32 log_charid)
 {
 {
 	nullpo_retr(-1,sd);
 	nullpo_retr(-1,sd);
 
 
@@ -5627,8 +5626,7 @@ char pc_getzeny(map_session_data *sd, int zeny, enum e_log_pick_type type, map_s
 	sd->status.zeny += zeny;
 	sd->status.zeny += zeny;
 	clif_updatestatus(sd,SP_ZENY);
 	clif_updatestatus(sd,SP_ZENY);
 
 
-	if(!tsd) tsd = sd;
-	log_zeny(sd, type, tsd, zeny);
+	log_zeny(*sd, type, log_charid, zeny);
 	if( zeny > 0 && sd->state.showzeny ) {
 	if( zeny > 0 && sd->state.showzeny ) {
 		char output[255];
 		char output[255];
 		sprintf(output, "Gained %dz.", zeny);
 		sprintf(output, "Gained %dz.", zeny);
@@ -6656,7 +6654,7 @@ int pc_steal_coin(map_session_data *sd,struct block_list *target)
 		// Zeny Steal Amount: (rnd() % (10 * target_lv + 1 - 8 * target_lv)) + 8 * target_lv
 		// Zeny Steal Amount: (rnd() % (10 * target_lv + 1 - 8 * target_lv)) + 8 * target_lv
 		int amount = (rnd() % (2 * target_lv + 1)) + 8 * target_lv; // Reduced formula
 		int amount = (rnd() % (2 * target_lv + 1)) + 8 * target_lv; // Reduced formula
 
 
-		pc_getzeny(sd, amount, LOG_TYPE_STEAL, NULL);
+		pc_getzeny(sd, amount, LOG_TYPE_STEAL);
 		md->state.steal_coin_flag = 1;
 		md->state.steal_coin_flag = 1;
 		return 1;
 		return 1;
 	}
 	}
@@ -9767,7 +9765,7 @@ int pc_dead(map_session_data *sd,struct block_list *src)
 		if( zeny_penalty > 0 && !mapdata->flag[MF_NOZENYPENALTY]) {
 		if( zeny_penalty > 0 && !mapdata->flag[MF_NOZENYPENALTY]) {
 			zeny_penalty = (uint32)( sd->status.zeny * ( zeny_penalty / 10000. ) );
 			zeny_penalty = (uint32)( sd->status.zeny * ( zeny_penalty / 10000. ) );
 			if(zeny_penalty)
 			if(zeny_penalty)
-				pc_payzeny(sd, zeny_penalty, LOG_TYPE_PICKDROP_PLAYER, NULL);
+				pc_payzeny(sd, zeny_penalty, LOG_TYPE_PICKDROP_PLAYER);
 		}
 		}
 	}
 	}
 
 
@@ -10162,7 +10160,7 @@ bool pc_setparam(map_session_data *sd,int64 type,int64 val_tmp)
 	case SP_ZENY:
 	case SP_ZENY:
 		if( val < 0 )
 		if( val < 0 )
 			return false;// can't set negative zeny
 			return false;// can't set negative zeny
-		log_zeny(sd, LOG_TYPE_SCRIPT, sd, -(sd->status.zeny - cap_value(val, 0, MAX_ZENY)));
+		log_zeny(*sd, LOG_TYPE_SCRIPT, sd->status.char_id, -(sd->status.zeny - cap_value(val, 0, MAX_ZENY)));
 		sd->status.zeny = cap_value(val, 0, MAX_ZENY);
 		sd->status.zeny = cap_value(val, 0, MAX_ZENY);
 		break;
 		break;
 	case SP_BASEEXP:
 	case SP_BASEEXP:
@@ -10301,7 +10299,7 @@ bool pc_setparam(map_session_data *sd,int64 type,int64 val_tmp)
 	case SP_BANK_VAULT:
 	case SP_BANK_VAULT:
 		if (val < 0)
 		if (val < 0)
 			return false;
 			return false;
-		log_zeny(sd, LOG_TYPE_BANK, sd, -(sd->bank_vault - cap_value(val, 0, MAX_BANK_ZENY)));
+		log_zeny(*sd, LOG_TYPE_BANK, sd->status.char_id, -(sd->bank_vault - cap_value(val, 0, MAX_BANK_ZENY)));
 		sd->bank_vault = cap_value(val, 0, MAX_BANK_ZENY);
 		sd->bank_vault = cap_value(val, 0, MAX_BANK_ZENY);
 		pc_setreg2(sd, BANK_VAULT_VAR, sd->bank_vault);
 		pc_setreg2(sd, BANK_VAULT_VAR, sd->bank_vault);
 		return true;
 		return true;
@@ -14534,7 +14532,7 @@ enum e_BANKING_DEPOSIT_ACK pc_bank_deposit(map_session_data *sd, int money) {
 		return BDA_NO_MONEY;
 		return BDA_NO_MONEY;
 	}
 	}
 
 
-	if( pc_payzeny(sd,money, LOG_TYPE_BANK, NULL) )
+	if( pc_payzeny(sd, money, LOG_TYPE_BANK) )
 		return BDA_NO_MONEY;
 		return BDA_NO_MONEY;
 
 
 	sd->bank_vault += money;
 	sd->bank_vault += money;
@@ -14562,7 +14560,7 @@ enum e_BANKING_WITHDRAW_ACK pc_bank_withdraw(map_session_data *sd, int money) {
 		return BWA_UNKNOWN_ERROR;
 		return BWA_UNKNOWN_ERROR;
 	}
 	}
 	
 	
-	if( pc_getzeny(sd,money, LOG_TYPE_BANK, NULL) )
+	if( pc_getzeny(sd,money, LOG_TYPE_BANK) )
 		return BWA_NO_MONEY;
 		return BWA_NO_MONEY;
 	
 	
 	sd->bank_vault -= money;
 	sd->bank_vault -= money;

+ 3 - 2
src/map/pc.hpp

@@ -789,6 +789,7 @@ public:
 		uint32 pending_weight;
 		uint32 pending_weight;
 		uint32 pending_zeny;
 		uint32 pending_zeny;
 		uint16 pending_slots;
 		uint16 pending_slots;
+		uint32 dest_id;
 	} mail;
 	} mail;
 
 
 	//Quest log system
 	//Quest log system
@@ -1418,9 +1419,9 @@ bool pc_memo(map_session_data* sd, int pos);
 char pc_checkadditem(map_session_data *sd, t_itemid nameid, int amount);
 char pc_checkadditem(map_session_data *sd, t_itemid nameid, int amount);
 uint8 pc_inventoryblank(map_session_data *sd);
 uint8 pc_inventoryblank(map_session_data *sd);
 short pc_search_inventory(map_session_data *sd, t_itemid nameid);
 short pc_search_inventory(map_session_data *sd, t_itemid nameid);
-char pc_payzeny(map_session_data *sd, int zeny, enum e_log_pick_type type, map_session_data *tsd);
+char pc_payzeny(map_session_data *sd, int zeny, enum e_log_pick_type type, uint32 log_charid = 0);
 enum e_additem_result pc_additem(map_session_data *sd, struct item *item, int amount, e_log_pick_type log_type);
 enum e_additem_result pc_additem(map_session_data *sd, struct item *item, int amount, e_log_pick_type log_type);
-char pc_getzeny(map_session_data *sd, int zeny, enum e_log_pick_type type, map_session_data *tsd);
+char pc_getzeny(map_session_data *sd, int zeny, enum e_log_pick_type type, uint32 log_charid = 0);
 char pc_delitem(map_session_data *sd, int n, int amount, int type, short reason, e_log_pick_type log_type);
 char pc_delitem(map_session_data *sd, int n, int amount, int type, short reason, e_log_pick_type log_type);
 
 
 uint64 pc_generate_unique_id(map_session_data *sd);
 uint64 pc_generate_unique_id(map_session_data *sd);

+ 1 - 1
src/map/script.cpp

@@ -13120,7 +13120,7 @@ BUILDIN_FUNC(warpwaitingpc)
 			{// no zeny to cover set fee
 			{// no zeny to cover set fee
 				break;
 				break;
 			}
 			}
-			pc_payzeny(sd, cd->zeny, LOG_TYPE_NPC, NULL);
+			pc_payzeny(sd, cd->zeny, LOG_TYPE_NPC);
 		}
 		}
 
 
 		mapreg_setreg(reference_uid(add_str("$@warpwaitingpc"), i), sd->bl.id);
 		mapreg_setreg(reference_uid(add_str("$@warpwaitingpc"), i), sd->bl.id);

+ 2 - 2
src/map/skill.cpp

@@ -7512,7 +7512,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
 		break;
 		break;
 	case SA_FORTUNE:
 	case SA_FORTUNE:
 		clif_skill_nodamage(src,bl,skill_id,skill_lv,1);
 		clif_skill_nodamage(src,bl,skill_id,skill_lv,1);
-		if(sd) pc_getzeny(sd,status_get_lv(bl)*100,LOG_TYPE_STEAL,NULL);
+		if(sd) pc_getzeny(sd,status_get_lv(bl)*100,LOG_TYPE_STEAL);
 		break;
 		break;
 	case SA_TAMINGMONSTER:
 	case SA_TAMINGMONSTER:
 		clif_skill_nodamage(src,bl,skill_id,skill_lv,1);
 		clif_skill_nodamage(src,bl,skill_id,skill_lv,1);
@@ -18272,7 +18272,7 @@ void skill_consume_requirement(map_session_data *sd, uint16 skill_id, uint16 ski
 				require.zeny = 0; //Zeny is reduced on skill_attack.
 				require.zeny = 0; //Zeny is reduced on skill_attack.
 			if( sd->status.zeny < require.zeny )
 			if( sd->status.zeny < require.zeny )
 				require.zeny = sd->status.zeny;
 				require.zeny = sd->status.zeny;
-			pc_payzeny(sd,require.zeny,LOG_TYPE_CONSUME,NULL);
+			pc_payzeny(sd,require.zeny,LOG_TYPE_CONSUME);
 		}
 		}
 	}
 	}
 
 

+ 4 - 4
src/map/trade.cpp

@@ -629,15 +629,15 @@ void trade_tradecommit(map_session_data *sd)
 	}
 	}
 
 
 	if( sd->deal.zeny ) {
 	if( sd->deal.zeny ) {
-		pc_payzeny(sd ,sd->deal.zeny, LOG_TYPE_TRADE, tsd);
-		pc_getzeny(tsd,sd->deal.zeny,LOG_TYPE_TRADE, sd);
+		pc_payzeny(sd ,sd->deal.zeny, LOG_TYPE_TRADE, tsd->status.char_id);
+		pc_getzeny(tsd,sd->deal.zeny,LOG_TYPE_TRADE, sd->status.char_id);
 		sd->deal.zeny = 0;
 		sd->deal.zeny = 0;
 
 
 	}
 	}
 
 
 	if ( tsd->deal.zeny) {
 	if ( tsd->deal.zeny) {
-		pc_payzeny(tsd,tsd->deal.zeny,LOG_TYPE_TRADE, sd);
-		pc_getzeny(sd ,tsd->deal.zeny,LOG_TYPE_TRADE, tsd);
+		pc_payzeny(tsd,tsd->deal.zeny,LOG_TYPE_TRADE, sd->status.char_id);
+		pc_getzeny(sd ,tsd->deal.zeny,LOG_TYPE_TRADE, tsd->status.char_id);
 		tsd->deal.zeny = 0;
 		tsd->deal.zeny = 0;
 	}
 	}
 
 

+ 2 - 2
src/map/vending.cpp

@@ -213,10 +213,10 @@ void vending_purchasereq(map_session_data* sd, int aid, int uid, const uint8* da
 		}
 		}
 	}
 	}
 
 
-	pc_payzeny(sd, (int)z, LOG_TYPE_VENDING, vsd);
+	pc_payzeny(sd, (int)z, LOG_TYPE_VENDING, vsd->status.char_id);
 	achievement_update_objective(sd, AG_SPEND_ZENY, 1, (int)z);
 	achievement_update_objective(sd, AG_SPEND_ZENY, 1, (int)z);
 	z = vending_calc_tax(sd, z);
 	z = vending_calc_tax(sd, z);
-	pc_getzeny(vsd, (int)z, LOG_TYPE_VENDING, sd);
+	pc_getzeny(vsd, (int)z, LOG_TYPE_VENDING, sd->status.char_id);
 
 
 	for( i = 0; i < count; i++ ) {
 	for( i = 0; i < count; i++ ) {
 		short amount = *(uint16*)(data + 4*i + 0);
 		short amount = *(uint16*)(data + 4*i + 0);