Browse Source

Converted most char-serv packets to struct

Lemongrass3110 3 months ago
parent
commit
ce0a41404f

+ 0 - 1
src/char/char-server.vcxproj

@@ -204,7 +204,6 @@
     <ClInclude Include="int_pet.hpp" />
     <ClInclude Include="int_quest.hpp" />
     <ClInclude Include="int_storage.hpp" />
-    <ClInclude Include="packets.hpp" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="char.cpp" />

+ 0 - 3
src/char/char-server.vcxproj.filters

@@ -65,9 +65,6 @@
     <ClInclude Include="int_clan.hpp">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="packets.hpp">
-      <Filter>Header Files</Filter>
-    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="char.cpp">

+ 66 - 73
src/char/char.cpp

@@ -19,6 +19,7 @@
 #include <common/malloc.hpp>
 #include <common/mapindex.hpp>
 #include <common/mmo.hpp>
+#include <common/packets.hpp>
 #include <common/random.hpp>
 #include <common/showmsg.hpp>
 #include <common/socket.hpp>
@@ -39,7 +40,6 @@
 #include "int_mercenary.hpp"
 #include "int_party.hpp"
 #include "int_storage.hpp"
-#include "packets.hpp"
 
 using namespace rathena;
 using namespace rathena::server_character;
@@ -895,11 +895,9 @@ int32 char_mmo_gender( const struct char_session_data *sd, const struct mmo_char
 #endif
 }
 
-int32 char_mmo_char_tobuf(uint8* buf, struct mmo_charstatus* p);
-
 //=====================================================================================================
 // Loads the basic character rooster for the given account. Returns total buffer used.
-int32 char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf, uint8* count ) {
+int32 char_mmo_chars_fromsql( char_session_data& sd, CHARACTER_INFO chars[], uint8* count ){
 	SqlStmt stmt{ *sql_handle };
 	struct mmo_charstatus p;
 	int32 j = 0, i;
@@ -908,8 +906,8 @@ int32 char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf, uint8* co
 	memset(&p, 0, sizeof(p));
 
 	for( i = 0; i < MAX_CHARS; i++ ) {
-		sd->found_char[i] = -1;
-		sd->unban_time[i] = 0;
+		sd.found_char[i] = -1;
+		sd.unban_time[i] = 0;
 	}
 
 	// read char data
@@ -922,7 +920,7 @@ int32 char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf, uint8* co
 		"`hotkey_rowshift2`,"
 		"`max_ap`,`ap`,`trait_point`,`pow`,`sta`,`wis`,`spl`,`con`,`crt`,"
 		"`inventory_slots`,`body_direction`,`disable_call`,`disable_partyinvite`"
-		" FROM `%s` WHERE `account_id`='%d' AND `char_num` < '%d'", schema_config.char_db, sd->account_id, MAX_CHARS)
+		" FROM `%s` WHERE `account_id`='%d' AND `char_num` < '%d'", schema_config.char_db, sd.account_id, MAX_CHARS )
 	||	SQL_ERROR == stmt.Execute()
 	||	SQL_ERROR == stmt.BindColumn( 0,  SQLDT_INT32,    &p.char_id, 0, nullptr, nullptr)
 	||	SQL_ERROR == stmt.BindColumn( 1,  SQLDT_UCHAR,  &p.slot, 0, nullptr, nullptr)
@@ -991,21 +989,21 @@ int32 char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf, uint8* co
 
 	for( i = 0; i < MAX_CHARS && SQL_SUCCESS == stmt.NextRow(); i++ )
 	{
-		sd->found_char[p.slot] = p.char_id;
-		sd->unban_time[p.slot] = p.unban_time;
-		p.sex = char_mmo_gender(sd, &p, sex[0]);
-		j += char_mmo_char_tobuf(WBUFP(buf, j), &p);
+		sd.found_char[p.slot] = p.char_id;
+		sd.unban_time[p.slot] = p.unban_time;
+		p.sex = char_mmo_gender( &sd, &p, sex[0] );
+		j += char_mmo_char_tobuf( chars[i], p );
 
 		// Addon System
 		// store the required info into the session
-		sd->char_moves[p.slot] = p.character_moves;
+		sd.char_moves[p.slot] = p.character_moves;
 	}
 
 	if( count != nullptr ){
 		*count = i;
 	}
 
-	memset(sd->new_name,0,sizeof(sd->new_name));
+	memset( sd.new_name, 0, sizeof( sd.new_name ) );
 
 	return j;
 }
@@ -1767,88 +1765,83 @@ int32 char_count_users(void)
 // Writes char data to the buffer in the format used by the client.
 // Used in packets 0x6b (chars info) and 0x6d (new char info)
 // Returns the size
-int32 char_mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p){
-	if( buffer == nullptr || p == nullptr )
-		return 0;
-
-	struct CHARACTER_INFO* info = (struct CHARACTER_INFO*)buffer;
-
-	info->GID = p->char_id;
+int32 char_mmo_char_tobuf( CHARACTER_INFO& info, mmo_charstatus& p ){
+	info.GID = p.char_id;
 #if PACKETVER >= 20170830
-	info->exp = u64min( p->base_exp, MAX_EXP );
+	info.exp = u64min( p.base_exp, MAX_EXP );
 #else
-	info->exp = (int32)u64min( p->base_exp, MAX_EXP );
+	info.exp = (int32)u64min( p.base_exp, MAX_EXP );
 #endif
-	info->money = p->zeny;
+	info.money = p.zeny;
 #if PACKETVER >= 20170830
-	info->jobexp = u64min( p->job_exp, MAX_EXP );
+	info.jobexp = u64min( p.job_exp, MAX_EXP );
 #else
-	info->jobexp = (int32)u64min( p->job_exp, MAX_EXP );
+	info.jobexp = (int32)u64min( p.job_exp, MAX_EXP );
 #endif
-	info->joblevel = p->job_level;
-	info->bodystate = 0; // probably opt1
-	info->healthstate = 0; // probably opt2
-	info->effectstate = p->option;
-	info->virtue = p->karma;
-	info->honor = p->manner;
-	info->jobpoint = umin( p->status_point, INT16_MAX );
-	info->hp = p->hp;
-	info->maxhp = p->max_hp;
-	info->sp = min( p->sp, INT16_MAX );
-	info->maxsp = min( p->max_sp, INT16_MAX );
-	info->speed = DEFAULT_WALK_SPEED; // p->speed;
-	info->job = p->class_;
-	info->head = p->hair;
+	info.joblevel = p.job_level;
+	info.bodystate = 0; // probably opt1
+	info.healthstate = 0; // probably opt2
+	info.effectstate = p.option;
+	info.virtue = p.karma;
+	info.honor = p.manner;
+	info.jobpoint = umin( p.status_point, INT16_MAX );
+	info.hp = p.hp;
+	info.maxhp = p.max_hp;
+	info.sp = min( p.sp, INT16_MAX );
+	info.maxsp = min( p.max_sp, INT16_MAX );
+	info.speed = DEFAULT_WALK_SPEED; // p.speed;
+	info.job = p.class_;
+	info.head = p.hair;
 #if PACKETVER >= 20141022
-	info->body = p->body;
+	info.body = p.body;
 #endif
 	//When the weapon is sent and your option is riding, the client crashes on login!?
-	info->weapon = p->option&(0x20|0x80000|0x100000|0x200000|0x400000|0x800000|0x1000000|0x2000000|0x4000000|0x8000000) ? 0 : p->weapon;
-	info->level = p->base_level;
-	info->sppoint = umin( p->skill_point, INT16_MAX );
-	info->accessory = p->head_bottom;
-	info->shield = p->shield;
-	info->accessory2 = p->head_top;
-	info->accessory3 = p->head_mid;
-	info->headpalette = p->hair_color;
-	info->bodypalette = p->clothes_color;
-	safestrncpy( info->name, p->name, NAME_LENGTH );
-	info->Str = (uint8)u16min( p->str, UINT8_MAX );
-	info->Agi = (uint8)u16min( p->agi, UINT8_MAX );
-	info->Vit = (uint8)u16min( p->vit, UINT8_MAX );
-	info->Int = (uint8)u16min( p->int_, UINT8_MAX );
-	info->Dex = (uint8)u16min( p->dex, UINT8_MAX );
-	info->Luk = (uint8)u16min( p->luk, UINT8_MAX );
-	info->CharNum = p->slot;
-	info->hairColor = (uint8)u16min( p->hair_color, UINT8_MAX );
-	info->bIsChangedCharName = ( p->rename > 0 ) ? 0 : 1;
+	info.weapon = p.option&(0x20|0x80000|0x100000|0x200000|0x400000|0x800000|0x1000000|0x2000000|0x4000000|0x8000000) ? 0 : p.weapon;
+	info.level = p.base_level;
+	info.sppoint = umin( p.skill_point, INT16_MAX );
+	info.accessory = p.head_bottom;
+	info.shield = p.shield;
+	info.accessory2 = p.head_top;
+	info.accessory3 = p.head_mid;
+	info.headpalette = p.hair_color;
+	info.bodypalette = p.clothes_color;
+	safestrncpy( info.name, p.name, NAME_LENGTH );
+	info.Str = (uint8)u16min( p.str, UINT8_MAX );
+	info.Agi = (uint8)u16min( p.agi, UINT8_MAX );
+	info.Vit = (uint8)u16min( p.vit, UINT8_MAX );
+	info.Int = (uint8)u16min( p.int_, UINT8_MAX );
+	info.Dex = (uint8)u16min( p.dex, UINT8_MAX );
+	info.Luk = (uint8)u16min( p.luk, UINT8_MAX );
+	info.CharNum = p.slot;
+	info.hairColor = (uint8)u16min( p.hair_color, UINT8_MAX );
+	info.bIsChangedCharName = ( p.rename > 0 ) ? 0 : 1;
 #if (PACKETVER >= 20100720 && PACKETVER <= 20100727) || PACKETVER >= 20100803
-	mapindex_getmapname_ext( p->last_point.map, info->mapName );
+	mapindex_getmapname_ext( p.last_point.map, info.mapName );
 #endif
 #if PACKETVER >= 20100803
 #if PACKETVER_CHAR_DELETEDATE
-	info->DelRevDate = ( p->delete_date ? TOL( p->delete_date - time( nullptr ) ) : 0 );
+	info.DelRevDate = ( p.delete_date ? TOL( p.delete_date - time( nullptr ) ) : 0 );
 #else
-	info->DelRevDate = TOL( p->delete_date );
+	info.DelRevDate = TOL( p.delete_date );
 #endif
 #endif
 #if PACKETVER >= 20110111
-	info->robePalette = p->robe;
+	info.robePalette = p.robe;
 #endif
 #if PACKETVER >= 20110928
 	// change slot feature (0 = disabled, otherwise enabled)
 	if( charserv_config.charmove_config.char_move_enabled == 0 )
-		info->chr_slot_changeCnt = 0;
+		info.chr_slot_changeCnt = 0;
 	else if( charserv_config.charmove_config.char_moves_unlimited )
-		info->chr_slot_changeCnt = 1;
+		info.chr_slot_changeCnt = 1;
 	else
-		info->chr_slot_changeCnt = max( 0, (int32)p->character_moves );
+		info.chr_slot_changeCnt = max( 0, (int32)p.character_moves );
 #endif
 #if PACKETVER >= 20111025
-	info->chr_name_changeCnt = ( p->rename > 0 ) ? 1 : 0; // (0 = disabled, otherwise displays "Add-Ons" sidebar)
+	info.chr_name_changeCnt = ( p.rename > 0 ) ? 1 : 0; // (0 = disabled, otherwise displays "Add-Ons" sidebar)
 #endif
 #if PACKETVER >= 20141016
-	info->sex = p->sex; // sex - (0 = female, 1 = male, 99 = logindefined)
+	info.sex = p.sex; // sex - (0 = female, 1 = male, 99 = logindefined)
 #endif
 
 	return sizeof( struct CHARACTER_INFO );
@@ -2119,15 +2112,15 @@ int32 parse_console(const char* buf){
 //------------------------------------------------
 //Pincode system
 //------------------------------------------------
-int32 char_pincode_compare( int32 fd, struct char_session_data* sd, char* pin ){
-	if( strcmp( sd->pincode, pin ) == 0 ){
-		sd->pincode_try = 0;
+int32 char_pincode_compare( int32 fd, char_session_data& sd, char* pin ){
+	if( strcmp( sd.pincode, pin ) == 0 ){
+		sd.pincode_try = 0;
 		return 1;
 	}else{
 		chclif_pincode_sendstate( fd, sd, PINCODE_WRONG );
 
-		if( charserv_config.pincode_config.pincode_maxtry && ++sd->pincode_try >= charserv_config.pincode_config.pincode_maxtry ){
-			chlogif_pincode_notifyLoginPinError( sd->account_id );
+		if( charserv_config.pincode_config.pincode_maxtry && ++sd.pincode_try >= charserv_config.pincode_config.pincode_maxtry ){
+			chlogif_pincode_notifyLoginPinError( sd.account_id );
 		}
 
 		return 0;

+ 4 - 5
src/char/char.hpp

@@ -11,11 +11,10 @@
 #include <common/core.hpp> // CORE_ST_LAST
 #include <common/mmo.hpp>
 #include <common/msg_conf.hpp>
+#include <common/packets.hpp>
 #include <common/timer.hpp>
 #include <config/core.hpp>
 
-#include "packets.hpp"
-
 using rathena::server_core::Core;
 using rathena::server_core::e_core_type;
 
@@ -304,10 +303,10 @@ void char_disconnect_player(uint32 account_id);
 TIMER_FUNC(char_chardb_waiting_disconnect);
 
 int32 char_mmo_gender(const struct char_session_data *sd, const struct mmo_charstatus *p, char sex);
-int32 char_mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p);
+int32 char_mmo_char_tobuf( CHARACTER_INFO& info, mmo_charstatus& p );
 int32 char_mmo_char_tosql(uint32 char_id, struct mmo_charstatus* p);
 int32 char_mmo_char_fromsql(uint32 char_id, struct mmo_charstatus* p, bool load_everything);
-int32 char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf, uint8* count = nullptr);
+int32 char_mmo_chars_fromsql( char_session_data& sd, CHARACTER_INFO chars[], uint8* count = nullptr );
 enum e_char_del_response char_delete(struct char_session_data* sd, uint32 char_id);
 int32 char_rename_char_sql(struct char_session_data *sd, uint32 char_id);
 int32 char_divorce_char_sql(int32 partner_id1, int32 partner_id2);
@@ -323,7 +322,7 @@ int32 char_loadName(uint32 char_id, char* name);
 int32 char_check_char_name(char * name, char * esc_name);
 
 bool char_pincode_decrypt( uint32 userSeed, char* pin );
-int32 char_pincode_compare( int32 fd, struct char_session_data* sd, char* pin );
+int32 char_pincode_compare( int32 fd, char_session_data& sd, char* pin );
 void char_auth_ok(int32 fd, struct char_session_data *sd);
 void char_set_charselect(uint32 account_id);
 void char_read_fame_list(void);

File diff suppressed because it is too large
+ 379 - 345
src/char/char_clif.cpp


+ 2 - 30
src/char/char_clif.hpp

@@ -10,47 +10,19 @@
 struct char_session_data;
 enum pincode_state : uint8;
 
-void chclif_moveCharSlotReply( int32 fd, struct char_session_data* sd, uint16 index, int16 reason );
-int32 chclif_parse_moveCharSlot( int32 fd, struct char_session_data* sd);
 #if PACKETVER_SUPPORTS_PINCODE
-void chclif_pincode_sendstate( int32 fd, struct char_session_data* sd, enum pincode_state state );
-int32 chclif_parse_reqpincode_window(int32 fd, struct char_session_data* sd);
-int32 chclif_parse_pincode_check( int32 fd, struct char_session_data* sd );
-int32 chclif_parse_pincode_change( int32 fd, struct char_session_data* sd );
-int32 chclif_parse_pincode_setnew( int32 fd, struct char_session_data* sd );
+void chclif_pincode_sendstate( int32 fd, char_session_data& sd, enum pincode_state state );
 #endif
 
 void chclif_reject(int32 fd, uint8 errCode);
 void chclif_refuse_delchar(int32 fd, uint8 errCode);
 void chclif_charlist_notify( int32 fd, struct char_session_data* sd );
-void chclif_block_character( int32 fd, struct char_session_data* sd );
-int32 chclif_mmo_send006b(int32 fd, struct char_session_data* sd);
-void chclif_mmo_send082d(int32 fd, struct char_session_data* sd);
-void chclif_mmo_send099d(int32 fd, struct char_session_data *sd);
-void chclif_mmo_char_send(int32 fd, struct char_session_data* sd);
+void chclif_mmo_char_send( int32 fd, char_session_data& sd );
 void chclif_send_auth_result(int32 fd,char result);
 void chclif_char_delete2_ack(int32 fd, uint32 char_id, uint32 result, time_t delete_date);
 void chclif_char_delete2_accept_ack(int32 fd, uint32 char_id, uint32 result);
 void chclif_char_delete2_cancel_ack(int32 fd, uint32 char_id, uint32 result);
 
-int32 chclif_parse_char_delete2_req(int32 fd, struct char_session_data* sd);
-int32 chclif_parse_char_delete2_accept(int32 fd, struct char_session_data* sd);
-int32 chclif_parse_char_delete2_cancel(int32 fd, struct char_session_data* sd);
-
-int32 chclif_parse_maplogin(int32 fd);
-int32 chclif_parse_reqtoconnect(int32 fd, struct char_session_data* sd,uint32 ipl);
-int32 chclif_parse_req_charlist(int32 fd, struct char_session_data* sd);
-int32 chclif_parse_charselect(int32 fd, struct char_session_data* sd,uint32 ipl);
-int32 chclif_parse_createnewchar(int32 fd, struct char_session_data* sd,int32 cmd);
-int32 chclif_parse_delchar(int32 fd,struct char_session_data* sd, int32 cmd);
-int32 chclif_parse_keepalive(int32 fd);
-int32 chclif_parse_reqrename(int32 fd, struct char_session_data* sd);
-int32 chclif_parse_ackrename(int32 fd, struct char_session_data* sd);
-int32 chclif_ack_captcha(int32 fd);
-int32 chclif_parse_reqcaptcha(int32 fd);
-int32 chclif_parse_chkcaptcha(int32 fd);
-void chclif_block_character( int32 fd, struct char_session_data* sd);
-
 int32 chclif_parse(int32 fd);
 
 #endif /* CHAR_CLIF_HPP */

+ 7 - 7
src/char/char_logif.cpp

@@ -56,9 +56,9 @@ void chlogif_pincode_start(int32 fd, struct char_session_data* sd){
 		if( sd->pincode[0] == '\0' ){
 			// No PIN code has been set yet
 			if( charserv_config.pincode_config.pincode_force ){
-				chclif_pincode_sendstate( fd, sd, PINCODE_NEW );
+				chclif_pincode_sendstate( fd, *sd, PINCODE_NEW );
 			}else{
-				chclif_pincode_sendstate( fd, sd, PINCODE_PASSED );
+				chclif_pincode_sendstate( fd, *sd, PINCODE_PASSED );
 			}
 		}else{
 			if( !(charserv_config.pincode_config.pincode_changetime)
@@ -67,20 +67,20 @@ void chlogif_pincode_start(int32 fd, struct char_session_data* sd){
 
 				if( node != nullptr && node->pincode_success ){
 					// User has already passed the check
-					chclif_pincode_sendstate( fd, sd, PINCODE_PASSED );
+					chclif_pincode_sendstate( fd, *sd, PINCODE_PASSED );
 				}else{
 					// Ask user for his PIN code
-					chclif_pincode_sendstate( fd, sd, PINCODE_ASK );
+					chclif_pincode_sendstate( fd, *sd, PINCODE_ASK );
 				}
 			}else{
 				// User hasnt changed his PIN code too long
-				chclif_pincode_sendstate( fd, sd, PINCODE_EXPIRED );
+				chclif_pincode_sendstate( fd, *sd, PINCODE_EXPIRED );
 			}
 		}
 	}else{
 		// PIN code system disabled
 		//ShowInfo("Pincode is disabled.\n");
-		chclif_pincode_sendstate( fd, sd, PINCODE_OK );
+		chclif_pincode_sendstate( fd, *sd, PINCODE_OK );
 	}
 }
 #endif
@@ -360,7 +360,7 @@ int32 chlogif_parse_reqaccdata(int32 fd){
 			chclif_reject(u_fd,0);
 		} else {
 			// send characters to player
-			chclif_mmo_char_send(u_fd, sd);
+			chclif_mmo_char_send( u_fd, *sd );
 #if PACKETVER_SUPPORTS_PINCODE
 			chlogif_pincode_start(u_fd,sd);
 #endif

+ 0 - 140
src/char/packets.hpp

@@ -1,140 +0,0 @@
-// Copyright (c) rAthena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
-
-#ifndef PACKETS_HPP
-#define PACKETS_HPP
-
-#include <common/mmo.hpp>
-
-#pragma warning( push )
-#pragma warning( disable : 4200 )
-
-// NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute
-#if !defined( sun ) && ( !defined( __NETBSD__ ) || __NetBSD_Version__ >= 600000000 )
-	#pragma pack( push, 1 )
-#endif
-
-struct CHARACTER_INFO{
-	uint32 GID;
-#if PACKETVER >= 20170830
-	int64 exp;
-#else
-	int32 exp;
-#endif
-	int32 money;
-#if PACKETVER >= 20170830
-	int64 jobexp;
-#else
-	int32 jobexp;
-#endif
-	int32 joblevel;
-	int32 bodystate;
-	int32 healthstate;
-	int32 effectstate;
-	int32 virtue;
-	int32 honor;
-	int16 jobpoint;
-#if PACKETVER_RE_NUM >= 20211103 || PACKETVER_MAIN_NUM >= 20220330
-	int64 hp;
-	int64 maxhp;
-	int64 sp;
-	int64 maxsp;
-#else
-	int32 hp;
-	int32 maxhp;
-	int16 sp;
-	int16 maxsp;
-#endif
-	int16 speed;
-	int16 job;
-	int16 head;
-#if PACKETVER >= 20141022
-	int16 body;
-#endif
-	int16 weapon;
-	int16 level;
-	int16 sppoint;
-	int16 accessory;
-	int16 shield;
-	int16 accessory2;
-	int16 accessory3;
-	int16 headpalette;
-	int16 bodypalette;
-	char name[24];
-	uint8 Str;
-	uint8 Agi;
-	uint8 Vit;
-	uint8 Int;
-	uint8 Dex;
-	uint8 Luk;
-	uint8 CharNum;
-	uint8 hairColor;
-	int16 bIsChangedCharName;
-#if (PACKETVER >= 20100720 && PACKETVER <= 20100727) || PACKETVER >= 20100803
-	char mapName[16];
-#endif
-#if PACKETVER >= 20100803
-	int32 DelRevDate;
-#endif
-#if PACKETVER >= 20110111
-	int32 robePalette;
-#endif
-#if PACKETVER >= 20110928
-	int32 chr_slot_changeCnt;
-#endif
-#if PACKETVER >= 20111025
-	int32 chr_name_changeCnt;
-#endif
-#if PACKETVER >= 20141016
-	uint8 sex;
-#endif
-} __attribute__((packed));
-
-struct PACKET_HC_NOTIFY_ACCESSIBLE_MAPNAME_sub{
-	int32 status;
-	char map[MAP_NAME_LENGTH_EXT];
-} __attribute__((packed));
-
-struct PACKET_HC_NOTIFY_ACCESSIBLE_MAPNAME{
-	int16 packetType;
-	int16 packetLength;
-	struct PACKET_HC_NOTIFY_ACCESSIBLE_MAPNAME_sub maps[];
-} __attribute__((packed));
-
-struct PACKET_CH_SELECT_ACCESSIBLE_MAPNAME{
-	int16 packetType;
-	int8 slot;
-	int8 mapnumber;
-} __attribute__((packed));
-
-#define DEFINE_PACKET_HEADER(name, id) const int16 HEADER_##name = id;
-
-#if PACKETVER_MAIN_NUM >= 20201007 || PACKETVER_RE_NUM >= 20211103
-	DEFINE_PACKET_HEADER( HC_ACK_CHANGE_CHARACTER_SLOT, 0xb70 )
-#else
-	DEFINE_PACKET_HEADER( HC_ACK_CHANGE_CHARACTER_SLOT, 0x8d5 )
-#endif
-#if PACKETVER_MAIN_NUM >= 20201007 || PACKETVER_RE_NUM >= 20211103
-	DEFINE_PACKET_HEADER( HC_ACK_CHARINFO_PER_PAGE, 0xb72 )
-#else
-	DEFINE_PACKET_HEADER( HC_ACK_CHARINFO_PER_PAGE, 0x99d )
-#endif
-#if PACKETVER_MAIN_NUM >= 20201007 || PACKETVER_RE_NUM >= 20211103
-	DEFINE_PACKET_HEADER( HC_ACCEPT_MAKECHAR, 0xb6f )
-#else
-	DEFINE_PACKET_HEADER( HC_ACCEPT_MAKECHAR, 0x6d )
-#endif
-
-DEFINE_PACKET_HEADER( HC_NOTIFY_ACCESSIBLE_MAPNAME, 0x840 )
-DEFINE_PACKET_HEADER( CH_SELECT_ACCESSIBLE_MAPNAME, 0x841 )
-
-#undef DEFINE_PACKET_HEADER
-
-// NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute
-#if !defined( sun ) && ( !defined( __NETBSD__ ) || __NetBSD_Version__ >= 600000000 )
-	#pragma pack( pop )
-#endif
-
-#pragma warning( pop )
-
-#endif /* PACKETS_HPP */

+ 436 - 0
src/common/packets.hpp

@@ -28,6 +28,82 @@ struct PACKET{
 	int16 packetLength;
 } __attribute__((packed));
 
+struct CHARACTER_INFO{
+	uint32 GID;
+#if PACKETVER >= 20170830
+	int64 exp;
+#else
+	int32 exp;
+#endif
+	int32 money;
+#if PACKETVER >= 20170830
+	int64 jobexp;
+#else
+	int32 jobexp;
+#endif
+	int32 joblevel;
+	int32 bodystate;
+	int32 healthstate;
+	int32 effectstate;
+	int32 virtue;
+	int32 honor;
+	int16 jobpoint;
+#if PACKETVER_RE_NUM >= 20211103 || PACKETVER_MAIN_NUM >= 20220330
+	int64 hp;
+	int64 maxhp;
+	int64 sp;
+	int64 maxsp;
+#else
+	int32 hp;
+	int32 maxhp;
+	int16 sp;
+	int16 maxsp;
+#endif
+	int16 speed;
+	int16 job;
+	int16 head;
+#if PACKETVER >= 20141022
+	int16 body;
+#endif
+	int16 weapon;
+	int16 level;
+	int16 sppoint;
+	int16 accessory;
+	int16 shield;
+	int16 accessory2;
+	int16 accessory3;
+	int16 headpalette;
+	int16 bodypalette;
+	char name[24];
+	uint8 Str;
+	uint8 Agi;
+	uint8 Vit;
+	uint8 Int;
+	uint8 Dex;
+	uint8 Luk;
+	uint8 CharNum;
+	uint8 hairColor;
+	int16 bIsChangedCharName;
+#if (PACKETVER >= 20100720 && PACKETVER <= 20100727) || PACKETVER >= 20100803
+	char mapName[16];
+#endif
+#if PACKETVER >= 20100803
+	int32 DelRevDate;
+#endif
+#if PACKETVER >= 20110111
+	int32 robePalette;
+#endif
+#if PACKETVER >= 20110928
+	int32 chr_slot_changeCnt;
+#endif
+#if PACKETVER >= 20111025
+	int32 chr_name_changeCnt;
+#endif
+#if PACKETVER >= 20141016
+	uint8 sex;
+#endif
+} __attribute__((packed));
+
 struct PACKET_CA_LOGIN{
 	int16 packetType;
 	uint32 version;
@@ -37,6 +113,65 @@ struct PACKET_CA_LOGIN{
 } __attribute__((packed));
 DEFINE_PACKET_HEADER( CA_LOGIN, 0x64 );
 
+struct PACKET_CH_SELECT_CHAR{
+	int16 packetType;
+	uint8 slot;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( CH_SELECT_CHAR, 0x66 );
+
+#if PACKETVER >= 20151001
+struct PACKET_CH_MAKE_CHAR{
+	int16 packetType;
+	char name[NAME_LENGTH];
+	uint8 slot;
+	uint16 hair_color;
+	uint16 hair_style;
+	uint32 job;
+	uint8 sex;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( CH_MAKE_CHAR, 0xa39 );
+#elif PACKETVER >= 20120307
+struct PACKET_CH_MAKE_CHAR{
+	int16 packetType;
+	char name[NAME_LENGTH];
+	uint8 slot;
+	uint16 hair_color;
+	uint16 hair_style;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( CH_MAKE_CHAR, 0x970 );
+#else
+struct PACKET_CH_MAKE_CHAR{
+	int16 packetType;
+	char name[NAME_LENGTH];
+	uint8 str;
+	uint8 agi;
+	uint8 vit;
+	uint8 int_;
+	uint8 dex;
+	uint8 luk;
+	uint8 slot;
+	uint16 hair_color;
+	uint16 hair_style;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( CH_MAKE_CHAR, 0x67 );
+#endif
+
+#if PACKETVER >= 20040419
+struct PACKET_CH_DELETE_CHAR{
+	int16 packetType;
+	uint32 CID;
+	char key[50];
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( CH_DELETE_CHAR, 0x1fb );
+#else
+struct PACKET_CH_DELETE_CHAR{
+	int16 packetType;
+	uint32 CID;
+	char key[40];
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( CH_DELETE_CHAR, 0x68 );
+#endif
+
 #if PACKETVER >= 20170315
 struct PACKET_AC_ACCEPT_LOGIN_sub{
 	uint32 ip;
@@ -102,12 +237,89 @@ struct PACKET_AC_REFUSE_LOGIN{
 DEFINE_PACKET_HEADER( AC_REFUSE_LOGIN, 0x6a );
 #endif
 
+struct PACKET_HC_ACCEPT_ENTER{
+	int16 packetType;
+	int16 packetLength;
+#if PACKETVER >= 20100413
+	uint8 total;
+	uint8 premium_start;
+	uint8 premium_end;
+#endif
+	char extension[20];
+	CHARACTER_INFO characters[];
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( HC_ACCEPT_ENTER, 0x6b );
+
+struct PACKET_HC_REFUSE_ENTER{
+	int16 packetType;
+	uint8 error;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( HC_REFUSE_ENTER, 0x6c );
+
+#if PACKETVER_MAIN_NUM >= 20201007 || PACKETVER_RE_NUM >= 20211103
+struct PACKET_HC_ACCEPT_MAKECHAR{
+	int16 packetType;
+	CHARACTER_INFO character;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( HC_ACCEPT_MAKECHAR, 0xb6f );
+#else
+struct PACKET_HC_ACCEPT_MAKECHAR{
+	int16 packetType;
+	CHARACTER_INFO character;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( HC_ACCEPT_MAKECHAR, 0x6d );
+#endif
+
+struct PACKET_HC_REFUSE_MAKECHAR{
+	int16 packetType;
+	uint8 error;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( HC_REFUSE_MAKECHAR, 0x6e );
+
+struct PACKET_HC_ACCEPT_DELETECHAR{
+	int16 packetType;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( HC_ACCEPT_DELETECHAR, 0x6f );
+
+struct PACKET_HC_REFUSE_DELETECHAR{
+	int16 packetType;
+	uint8 error;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( HC_REFUSE_DELETECHAR, 0x70 );
+
+#if PACKETVER >= 20170315
+struct PACKET_HC_NOTIFY_ZONESVR{
+	int16 packetType;
+	uint32 CID;
+	char mapname[MAP_NAME_LENGTH_EXT];
+	uint32 ip;
+	uint16 port;
+	char domain[128];
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( HC_NOTIFY_ZONESVR, 0xac5 );
+#else
+struct PACKET_HC_NOTIFY_ZONESVR{
+	int16 packetType;
+	uint32 CID;
+	char mapname[MAP_NAME_LENGTH_EXT];
+	uint32 ip;
+	uint16 port;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( HC_NOTIFY_ZONESVR, 0x81 );
+#endif
+
 struct PACKET_SC_NOTIFY_BAN{
 	int16 packetType;
 	uint8 result;
 } __attribute__((packed));
 DEFINE_PACKET_HEADER( SC_NOTIFY_BAN, 0x81 );
 
+struct PACKET_PING{
+	int16 packetType;
+	uint32 AID;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( PING, 0x187 );
+
 struct PACKET_CA_REQ_HASH{
 	int16 packetType;
 } __attribute__((packed));
@@ -151,6 +363,18 @@ struct PACKET_CA_EXE_HASHCHECK{
 } __attribute__((packed));
 DEFINE_PACKET_HEADER( CA_EXE_HASHCHECK, 0x204 );
 
+struct PACKET_HC_BLOCK_CHARACTER_sub{
+	uint32 CID;
+	char unblock_time[20];
+} __attribute__((packed));
+
+struct PACKET_HC_BLOCK_CHARACTER{
+	int16 packetType;
+	int16 packetLength;
+	PACKET_HC_BLOCK_CHARACTER_sub characters[];
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( HC_BLOCK_CHARACTER, 0x20d );
+
 struct PACKET_CA_LOGIN_PCBANG{
 	int16 packetType;
 	uint32 version;
@@ -172,6 +396,49 @@ struct PACKET_CA_LOGIN4{
 } __attribute__((packed));
 DEFINE_PACKET_HEADER( CA_LOGIN4, 0x27c );
 
+struct PACKET_CH_REQ_IS_VALID_CHARNAME{
+	int16 packetType;
+	uint32 AID;
+	uint32 CID;
+	char new_name[NAME_LENGTH];
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( CH_REQ_IS_VALID_CHARNAME, 0x28d );
+
+struct PACKET_HC_ACK_IS_VALID_CHARNAME{
+	int16 packetType;
+	uint16 result;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( HC_ACK_IS_VALID_CHARNAME, 0x28e );
+
+#if PACKETVER >= 20111101
+struct PACKET_CH_REQ_CHANGE_CHARNAME{
+	int16 packetType;
+	uint32 CID;
+	char new_name[NAME_LENGTH];
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( CH_REQ_CHANGE_CHARNAME, 0x8fc );
+#else
+struct PACKET_CH_REQ_CHANGE_CHARNAME{
+	int16 packetType;
+	uint32 CID;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( CH_REQ_CHANGE_CHARNAME, 0x28f );
+#endif
+
+#if PACKETVER >= 20111101
+struct PACKET_HC_ACK_CHANGE_CHARNAME{
+	int16 packetType;
+	uint32 result;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( HC_ACK_CHANGE_CHARNAME, 0x8fd );
+#else
+struct PACKET_HC_ACK_CHANGE_CHARNAME{
+	int16 packetType;
+	uint16 result;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( HC_ACK_CHANGE_CHARNAME, 0x290 );
+#endif
+
 struct PACKET_CA_LOGIN_CHANNEL{
 	int16 packetType;
 	uint32 version;
@@ -197,6 +464,170 @@ struct PACKET_CA_SSO_LOGIN_REQ{
 } __attribute__((packed));
 DEFINE_PACKET_HEADER( CA_SSO_LOGIN_REQ, 0x825 );
 
+struct PACKET_CH_DELETE_CHAR3_RESERVED{
+	int16 packetType;
+	uint32 CID;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( CH_DELETE_CHAR3_RESERVED, 0x827 );
+
+struct PACKET_HC_DELETE_CHAR3_RESERVED{
+	int16 packetType;
+	uint32 CID;
+	int32 result;
+	uint32 date;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( HC_DELETE_CHAR3_RESERVED, 0x828 );
+
+struct PACKET_CH_DELETE_CHAR3{
+	int16 packetType;
+	uint32 CID;
+	char birthdate[6];
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( CH_DELETE_CHAR3, 0x829 );
+
+struct PACKET_HC_DELETE_CHAR3{
+	int16 packetType;
+	uint32 CID;
+	int32 result;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( HC_DELETE_CHAR3, 0x82a );
+
+struct PACKET_CH_DELETE_CHAR3_CANCEL{
+	int16 packetType;
+	uint32 CID;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( CH_DELETE_CHAR3_CANCEL, 0x82b );
+
+struct PACKET_HC_DELETE_CHAR3_CANCEL{
+	int16 packetType;
+	uint32 CID;
+	int32 result;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( HC_DELETE_CHAR3_CANCEL, 0x82c );
+
+struct PACKET_HC_ACCEPT_ENTER2{
+	int16 packetType;
+	int16 packetLength;
+	uint8 normal;
+	uint8 premium;
+	uint8 billing;
+	uint8 producible;
+	uint8 total;
+	char extension[20];
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( HC_ACCEPT_ENTER2, 0x82d );
+
+struct PACKET_HC_NOTIFY_ACCESSIBLE_MAPNAME_sub{
+	int32 status;
+	char map[MAP_NAME_LENGTH_EXT];
+} __attribute__((packed));
+
+struct PACKET_HC_NOTIFY_ACCESSIBLE_MAPNAME{
+	int16 packetType;
+	int16 packetLength;
+	struct PACKET_HC_NOTIFY_ACCESSIBLE_MAPNAME_sub maps[];
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( HC_NOTIFY_ACCESSIBLE_MAPNAME, 0x840 );
+
+struct PACKET_CH_SELECT_ACCESSIBLE_MAPNAME{
+	int16 packetType;
+	int8 slot;
+	int8 mapnumber;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( CH_SELECT_ACCESSIBLE_MAPNAME, 0x841 );
+
+struct PACKET_CH_SECOND_PASSWD_ACK{
+	int16 packetType;
+	uint32 AID;
+	char pin[4];
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( CH_SECOND_PASSWD_ACK, 0x8b8 );
+
+struct PACKET_HC_SECOND_PASSWD_LOGIN{
+	int16 packetType;
+	uint32 seed;
+	uint32 AID;
+	uint16 result;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( HC_SECOND_PASSWD_LOGIN, 0x8b9 );
+
+struct PACKET_CH_MAKE_SECOND_PASSWD{
+	int16 packetType;
+	uint32 AID;
+	char pin[4];
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( CH_MAKE_SECOND_PASSWD, 0x8ba );
+
+struct PACKET_CH_EDIT_SECOND_PASSWD{
+	int16 packetType;
+	uint32 AID;
+	char old_pin[4];
+	char new_pin[4];
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( CH_EDIT_SECOND_PASSWD, 0x8be );
+
+struct PACKET_CH_AVAILABLE_SECOND_PASSWD{
+	int16 packetType;
+	uint32 AID;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( CH_AVAILABLE_SECOND_PASSWD, 0x8c5 );
+
+struct PACKET_CH_REQ_CHANGE_CHARACTER_SLOT{
+	int16 packetType;
+	uint16 slot_before;
+	uint16 slot_after;
+	uint16 remaining;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( CH_REQ_CHANGE_CHARACTER_SLOT, 0x8d4 );
+
+#if PACKETVER_MAIN_NUM >= 20201007 || PACKETVER_RE_NUM >= 20211103
+struct PACKET_HC_ACK_CHANGE_CHARACTER_SLOT{
+	int16 packetType;
+	int16 packetLength;
+	uint16 reason;
+	uint16 moves;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( HC_ACK_CHANGE_CHARACTER_SLOT, 0xb70 );
+#else
+struct PACKET_HC_ACK_CHANGE_CHARACTER_SLOT{
+	int16 packetType;
+	int16 packetLength;
+	uint16 reason;
+	uint16 moves;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( HC_ACK_CHANGE_CHARACTER_SLOT, 0x8d5 );
+#endif
+
+#if PACKETVER_MAIN_NUM >= 20201007 || PACKETVER_RE_NUM >= 20211103
+struct PACKET_HC_ACK_CHARINFO_PER_PAGE{
+	int16 packetType;
+	int16 packetLength;
+	CHARACTER_INFO characters[];
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( HC_ACK_CHARINFO_PER_PAGE, 0xb72 );
+#else
+struct PACKET_HC_ACK_CHARINFO_PER_PAGE{
+	int16 packetType;
+	int16 packetLength;
+	CHARACTER_INFO characters[];
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( HC_ACK_CHARINFO_PER_PAGE, 0x99d );
+#endif
+
+struct PACKET_HC_CHARLIST_NOTIFY{
+	int16 packetType;
+	uint32 total;
+#if PACKETVER_RE_NUM >= 20151001 && PACKETVER_RE_NUM < 20180103
+	uint32 slots;
+#endif
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( HC_CHARLIST_NOTIFY, 0x9a0 );
+
+struct PACKET_CH_CHARLIST_REQ{
+	int16 packetType;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER( CH_CHARLIST_REQ, 0x9a1 );
+
 struct PACKET_CT_AUTH{
 	int16 packetType;
 	uint8 unknown[66];
@@ -243,6 +674,11 @@ public:
 			}
 		}
 
+		if( rathena::util::umap_find( this->infos, packetType ) != nullptr ){
+			ShowError( "Definition for packet 0x%04x is done at least twice.\n", packetType );
+			return;
+		}
+
 		s_packet_info& info = infos[packetType];
 
 		info.fixed = fixed;

Some files were not shown because too many files changed in this diff