Skip to content

Commit

Permalink
Data alignement
Browse files Browse the repository at this point in the history
Align account_id and char_id to uint32 as this is the value they can be
in DB.
Remove src/test folder, unused
Remove useless #include to speedup compilation.
  • Loading branch information
lighta committed Dec 20, 2014
1 parent 73c4c76 commit 8066bde
Show file tree
Hide file tree
Showing 106 changed files with 587 additions and 1,208 deletions.
6 changes: 0 additions & 6 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ endif
map \
tools \
import \
test \
clean help \
install uninstall bin-clean \

Expand Down Expand Up @@ -60,9 +59,6 @@ libconfig:
tools:
@$(MAKE) -C src/tool

test:
@$(MAKE) -C src/test

import:
# 1) create conf/import folder
# 2) add missing files
Expand All @@ -86,7 +82,6 @@ clean:
@$(MAKE) -C src/char $@
@$(MAKE) -C src/map $@
@$(MAKE) -C src/tool $@
@$(MAKE) -C src/test $@

help:
@echo "most common targets are 'all' 'server' 'conf' 'clean' 'help'"
Expand All @@ -101,7 +96,6 @@ help:
@echo "'import' - builds conf/import, conf/msg_conf/import and db/import folders from their template folders (x-tmpl)"
@echo "'all' - builds all the above targets"
@echo "'server' - builds servers (targets 'common' 'login' 'char' 'map' and 'import')"
@echo "'test' - builds tests"
@echo "'clean' - cleans builds and objects"
@echo "'install' - run installer wich setup rathena in /opt/"
@echo "'bin-clean' - delete binary installed"
Expand Down
3 changes: 0 additions & 3 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -2177,8 +2177,6 @@ ac_config_files="$ac_config_files src/char/Makefile src/login/Makefile"
ac_config_files="$ac_config_files src/map/Makefile src/tool/Makefile"
ac_config_files="$ac_config_files src/test/Makefile"
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
Expand Down Expand Up @@ -8115,7 +8113,6 @@ do
"src/login/Makefile") CONFIG_FILES="$CONFIG_FILES src/login/Makefile" ;;
"src/map/Makefile") CONFIG_FILES="$CONFIG_FILES src/map/Makefile" ;;
"src/tool/Makefile") CONFIG_FILES="$CONFIG_FILES src/tool/Makefile" ;;
"src/test/Makefile") CONFIG_FILES="$CONFIG_FILES src/test/Makefile" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
esac
Expand Down
1 change: 0 additions & 1 deletion configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ AC_CONFIG_FILES([Makefile src/common/Makefile])
AC_CONFIG_FILES([3rdparty/mt19937ar/Makefile 3rdparty/libconfig/Makefile])
AC_CONFIG_FILES([src/char/Makefile src/login/Makefile])
AC_CONFIG_FILES([src/map/Makefile src/tool/Makefile])
AC_CONFIG_FILES([src/test/Makefile])

AC_GNU_SOURCE

Expand Down
36 changes: 16 additions & 20 deletions src/char/char.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
// For more information, see LICENCE in the main folder

#include <time.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <string.h>

#include "../common/cbasetypes.h"
Expand All @@ -19,10 +17,7 @@
#include "../common/socket.h"
#include "../common/strlib.h"
#include "../common/timer.h"
#include "../common/utils.h"
#include "../common/cli.h"
#include "../common/random.h"
#include "../common/ers.h"
#include "int_guild.h"
#include "int_homun.h"
#include "int_mercenary.h"
Expand All @@ -34,7 +29,6 @@
#include "char_mapif.h"
#include "char_cnslif.h"
#include "char_clif.h"
#include "char.h"

//definition of exported var declared in .h
int login_fd=-1; //login file descriptor
Expand Down Expand Up @@ -76,9 +70,9 @@ int subnet_count = 0;

int char_chardb_waiting_disconnect(int tid, unsigned int tick, int id, intptr_t data);

DBMap* auth_db; // int account_id -> struct auth_node*
DBMap* online_char_db; // int account_id -> struct online_char_data*
DBMap* char_db_; // int char_id -> struct mmo_charstatus*
DBMap* auth_db; // uint32 account_id -> struct auth_node*
DBMap* online_char_db; // uint32 account_id -> struct online_char_data*
DBMap* char_db_; // uint32 char_id -> struct mmo_charstatus*
DBMap* char_get_authdb() { return auth_db; }
DBMap* char_get_onlinedb() { return online_char_db; }
DBMap* char_get_chardb() { return char_db_; }
Expand All @@ -97,7 +91,7 @@ DBData char_create_online_data(DBKey key, va_list args){
return db_ptr2data(character);
}

void char_set_charselect(int account_id) {
void char_set_charselect(uint32 account_id) {
struct online_char_data* character;

character = (struct online_char_data*)idb_ensure(online_char_db, account_id, char_create_online_data);
Expand All @@ -118,7 +112,7 @@ void char_set_charselect(int account_id) {

}

void char_set_char_online(int map_id, int char_id, int account_id) {
void char_set_char_online(int map_id, uint32 char_id, uint32 account_id) {
struct online_char_data* character;
struct mmo_charstatus *cp;

Expand Down Expand Up @@ -156,7 +150,7 @@ void char_set_char_online(int map_id, int char_id, int account_id) {
chlogif_send_setacconline(account_id);
}

void char_set_char_offline(int char_id, int account_id){
void char_set_char_offline(uint32 char_id, uint32 account_id){
struct online_char_data* character;

if ( char_id == -1 )
Expand Down Expand Up @@ -277,7 +271,7 @@ static DBData char_create_charstatus(DBKey key, va_list args) {

int char_inventory_to_sql(const struct item items[], int max, int id);

int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p){
int char_mmo_char_tosql(uint32 char_id, struct mmo_charstatus* p){
int i = 0;
int count = 0;
int diff = 0;
Expand Down Expand Up @@ -948,7 +942,7 @@ int char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf) {
}

//=====================================================================================================
int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything) {
int char_mmo_char_fromsql(uint32 char_id, struct mmo_charstatus* p, bool load_everything) {
int i,j;
char t_msg[128] = "";
struct mmo_charstatus* cp;
Expand Down Expand Up @@ -1255,7 +1249,7 @@ int char_mmo_sql_init(void) {
//-----------------------------------
// Function to change chararcter's names
//-----------------------------------
int char_rename_char_sql(struct char_session_data *sd, int char_id)
int char_rename_char_sql(struct char_session_data *sd, uint32 char_id)
{
struct mmo_charstatus char_dat;
char esc_name[NAME_LENGTH*2+1];
Expand Down Expand Up @@ -1365,7 +1359,8 @@ int char_make_new_char_sql(struct char_session_data* sd, char* name_, int str, i
#endif
char name[NAME_LENGTH];
char esc_name[NAME_LENGTH*2+1];
int char_id, flag, k;
uint32 char_id;
int flag, k;

safestrncpy(name, name_, NAME_LENGTH);
normalize_name(name,TRIM_CHARS);
Expand Down Expand Up @@ -1465,10 +1460,11 @@ int char_divorce_char_sql(int partner_id1, int partner_id2){
/* Returns 0 if successful
* Returns < 0 for error
*/
int char_delete_char_sql(int char_id){
int char_delete_char_sql(uint32 char_id){
char name[NAME_LENGTH];
char esc_name[NAME_LENGTH*2+1]; //Name needs be escaped.
int account_id, party_id, guild_id, hom_id, base_level, partner_id, father_id, mother_id, elemental_id;
uint32 account_id;
int party_id, guild_id, hom_id, base_level, partner_id, father_id, mother_id, elemental_id;
char *data;
size_t len;

Expand Down Expand Up @@ -1802,7 +1798,7 @@ int char_family(int cid1, int cid2, int cid3)
//----------------------------------------------------------------------
// Force disconnection of an online player (with account value) by [Yor]
//----------------------------------------------------------------------
void char_disconnect_player(int account_id)
void char_disconnect_player(uint32 account_id)
{
int i;
struct char_session_data* sd;
Expand Down Expand Up @@ -1907,7 +1903,7 @@ void char_read_fame_list(void)

//Loads a character's name and stores it in the buffer given (must be NAME_LENGTH in size)
//Returns 1 on found, 0 on not found (buffer is filled with Unknown char name)
int char_loadName(int char_id, char* name){
int char_loadName(uint32 char_id, char* name){
char* data;
size_t len;

Expand Down
39 changes: 20 additions & 19 deletions src/char/char.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ extern struct mmo_map_server map_server[MAX_MAP_SERVERS];

#define AUTH_TIMEOUT 30000
struct auth_node {
int account_id;
int char_id;
uint32 account_id;
uint32 char_id;
uint32 login_id1;
uint32 login_id2;
uint32 ip;
Expand All @@ -161,21 +161,22 @@ struct auth_node {
unsigned changing_mapservers : 1;
uint8 version;
};
DBMap* char_get_authdb(); // int account_id -> struct auth_node*
DBMap* char_get_authdb(); // uint32 account_id -> struct auth_node*

struct online_char_data {
int account_id;
int char_id;
uint32 account_id;
uint32 char_id;
int fd;
int waiting_disconnect;
short server; // -2: unknown server, -1: not connected, 0+: id of server
bool pincode_success;
};
DBMap* char_get_onlinedb(); // int account_id -> struct online_char_data*
DBMap* char_get_onlinedb(); // uint32 account_id -> struct online_char_data*

struct char_session_data {
bool auth; // whether the session is authed or not
int account_id, login_id1, login_id2, sex;
uint32 account_id, login_id1, login_id2;
int sex;
int found_char[MAX_CHARS]; // ids of chars on this account
char email[40]; // e-mail (default: [email protected]) by [Yor]
time_t expiration_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited)
Expand All @@ -202,7 +203,7 @@ struct char_session_data {


struct mmo_charstatus;
DBMap* char_get_chardb(); // int char_id -> struct mmo_charstatus*
DBMap* char_get_chardb(); // uint32 char_id -> struct mmo_charstatus*

//Custom limits for the fame lists. [Skotlex]
extern int fame_list_size_chemist;
Expand All @@ -222,38 +223,38 @@ int char_lan_subnetcheck(uint32 ip);
int char_count_users(void);
DBData char_create_online_data(DBKey key, va_list args);
int char_db_setoffline(DBKey key, DBData *data, va_list ap);
void char_set_char_online(int map_id, int char_id, int account_id);
void char_set_char_offline(int char_id, int account_id);
void char_set_char_online(int map_id, uint32 char_id, uint32 account_id);
void char_set_char_offline(uint32 char_id, uint32 account_id);
void char_set_all_offline(int id);
void char_disconnect_player(int account_id);
void char_disconnect_player(uint32 account_id);
int char_chardb_waiting_disconnect(int tid, unsigned int tick, int id, intptr_t data);

int char_mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p);
int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p);
int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything);
int char_mmo_char_tosql(uint32 char_id, struct mmo_charstatus* p);
int char_mmo_char_fromsql(uint32 char_id, struct mmo_charstatus* p, bool load_everything);
int char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf);
int char_delete_char_sql(int char_id);
int char_rename_char_sql(struct char_session_data *sd, int char_id);
int char_delete_char_sql(uint32 char_id);
int char_rename_char_sql(struct char_session_data *sd, uint32 char_id);
int char_divorce_char_sql(int partner_id1, int partner_id2);
int char_memitemdata_to_sql(const struct item items[], int max, int id, int tableswitch);

void disconnect_player(int account_id);
void disconnect_player(uint32 account_id);

int char_married(int pl1,int pl2);
int char_child(int parent_id, int child_id);
int char_family(int pl1,int pl2,int pl3);

int char_request_accreg2(int account_id, int char_id);
int char_request_accreg2(uint32 account_id, uint32 char_id);
int char_save_accreg2(unsigned char* buf, int len);

//extern bool char_gm_read;
int char_loadName(int char_id, char* name);
int char_loadName(uint32 char_id, char* name);
int char_check_char_name(char * name, char * esc_name);

void char_pincode_decrypt( uint32 userSeed, char* pin );
int char_pincode_compare( int fd, struct char_session_data* sd, char* pin );
void char_auth_ok(int fd, struct char_session_data *sd);
void char_set_charselect(int account_id);
void char_set_charselect(uint32 account_id);
void char_read_fame_list(void);

#if PACKETVER >= 20120307
Expand Down
24 changes: 12 additions & 12 deletions src/char/char_clif.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
#include "char_mapif.h"
#include "char_clif.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>


//------------------------------------------------
Expand Down Expand Up @@ -319,7 +317,7 @@ void chclif_send_auth_result(int fd,char result){
/// 5 (0x71b): To delete a character you must withdraw from the party.
/// Any (0x718): An unknown error has occurred.
/// HC: <0828>.W <char id>.L <Msg:0-5>.L <deleteDate>.L
void chclif_char_delete2_ack(int fd, int char_id, uint32 result, time_t delete_date) {
void chclif_char_delete2_ack(int fd, uint32 char_id, uint32 result, time_t delete_date) {
WFIFOHEAD(fd,14);
WFIFOW(fd,0) = 0x828;
WFIFOL(fd,2) = char_id;
Expand All @@ -337,7 +335,7 @@ void chclif_char_delete2_ack(int fd, int char_id, uint32 result, time_t delete_d
/// 5 (0x71e): Date of birth do not match.
/// Any (0x718): An unknown error has occurred.
/// HC: <082a>.W <char id>.L <Msg:0-5>.L
void chclif_char_delete2_accept_ack(int fd, int char_id, uint32 result) {
void chclif_char_delete2_accept_ack(int fd, uint32 char_id, uint32 result) {
if(result == 1 ){
struct char_session_data* sd;
sd = (struct char_session_data*)session[fd]->session_data;
Expand All @@ -359,7 +357,7 @@ void chclif_char_delete2_accept_ack(int fd, int char_id, uint32 result) {
/// 2 (0x719): A database error occurred.
/// Any (0x718): An unknown error has occurred.
/// HC: <082c>.W <char id>.L <Msg:1-2>.L
void chclif_char_delete2_cancel_ack(int fd, int char_id, uint32 result) {
void chclif_char_delete2_cancel_ack(int fd, uint32 char_id, uint32 result) {
WFIFOHEAD(fd,10);
WFIFOW(fd,0) = 0x82c;
WFIFOL(fd,2) = char_id;
Expand All @@ -369,9 +367,9 @@ void chclif_char_delete2_cancel_ack(int fd, int char_id, uint32 result) {

// CH: <0827>.W <char id>.L
int chclif_parse_char_delete2_req(int fd, struct char_session_data* sd) {
FIFOSD_CHECK(6)
{
int char_id, i;
FIFOSD_CHECK(6)
{
uint32 char_id, i;
char* data;
time_t delete_date;

Expand Down Expand Up @@ -435,7 +433,8 @@ int chclif_parse_char_delete2_accept(int fd, struct char_session_data* sd) {
FIFOSD_CHECK(12)
{
char birthdate[8+1];
int char_id, i, k;
uint32 char_id;
int i, k;
unsigned int base_level;
char* data;
time_t delete_date;
Expand Down Expand Up @@ -510,7 +509,8 @@ int chclif_parse_char_delete2_accept(int fd, struct char_session_data* sd) {

// CH: <082b>.W <char id>.L
int chclif_parse_char_delete2_cancel(int fd, struct char_session_data* sd) {
int char_id, i;
uint32 char_id;
int i;

FIFOSD_CHECK(6)

Expand Down Expand Up @@ -590,7 +590,7 @@ int chclif_parse_reqtoconnect(int fd, struct char_session_data* sd,uint32 ipl){
struct auth_node* node;
DBMap *auth_db = char_get_authdb();

int account_id = RFIFOL(fd,2);
uint32 account_id = RFIFOL(fd,2);
uint32 login_id1 = RFIFOL(fd,6);
uint32 login_id2 = RFIFOL(fd,10);
int sex = RFIFOB(fd,16);
Expand Down Expand Up @@ -678,7 +678,7 @@ int chclif_parse_charselect(int fd, struct char_session_data* sd,uint32 ipl){
struct mmo_charstatus char_dat;
struct mmo_charstatus *cd;
char* data;
int char_id;
uint32 char_id;
uint32 subnet_map_ip;
struct auth_node* node;
int i, map_fd;
Expand Down
6 changes: 3 additions & 3 deletions src/char/char_clif.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ void chclif_mmo_send082d(int fd, struct char_session_data* sd);
void chclif_mmo_send099d(int fd, struct char_session_data *sd);
void chclif_mmo_char_send(int fd, struct char_session_data* sd);
void chclif_send_auth_result(int fd,char result);
void chclif_char_delete2_ack(int fd, int char_id, uint32 result, time_t delete_date);
void chclif_char_delete2_accept_ack(int fd, int char_id, uint32 result);
void chclif_char_delete2_cancel_ack(int fd, int char_id, uint32 result);
void chclif_char_delete2_ack(int fd, uint32 char_id, uint32 result, time_t delete_date);
void chclif_char_delete2_accept_ack(int fd, uint32 char_id, uint32 result);
void chclif_char_delete2_cancel_ack(int fd, uint32 char_id, uint32 result);

int chclif_parse_char_delete2_req(int fd, struct char_session_data* sd);
int chclif_parse_char_delete2_accept(int fd, struct char_session_data* sd);
Expand Down
Loading

0 comments on commit 8066bde

Please sign in to comment.