commit
6b9ec5fe0b
@ -12,6 +12,10 @@ if( BUILD_SQL_SERVERS )
|
||||
message( STATUS "Creating target char-server_sql" )
|
||||
set( SQL_CHAR_HEADERS
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/char.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/char_clif.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/char_cnslif.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/char_logif.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/char_mapif.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_auction.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_elemental.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_guild.h"
|
||||
@ -26,6 +30,10 @@ set( SQL_CHAR_HEADERS
|
||||
)
|
||||
set( SQL_CHAR_SOURCES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/char.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/char_clif.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/char_cnslif.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/char_logif.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/char_mapif.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_auction.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_elemental.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_guild.c"
|
||||
|
4266
src/char/char.c
4266
src/char/char.c
File diff suppressed because it is too large
Load Diff
301
src/char/char.h
301
src/char/char.h
@ -4,31 +4,24 @@
|
||||
#ifndef _CHAR_SQL_H_
|
||||
#define _CHAR_SQL_H_
|
||||
|
||||
#define DB_NAME_LEN 256 //max len of dbs
|
||||
|
||||
#include "../config/core.h"
|
||||
#include "../common/core.h" // CORE_ST_LAST
|
||||
#include "../common/msg_conf.h"
|
||||
#include "../common/mmo.h"
|
||||
|
||||
enum E_CHARSERVER_ST
|
||||
{
|
||||
|
||||
extern int login_fd; //login file descriptor
|
||||
extern int char_fd; //char file descriptor
|
||||
|
||||
enum E_CHARSERVER_ST {
|
||||
CHARSERVER_ST_RUNNING = CORE_ST_LAST,
|
||||
CHARSERVER_ST_STARTING,
|
||||
CHARSERVER_ST_SHUTDOWN,
|
||||
CHARSERVER_ST_LAST
|
||||
};
|
||||
|
||||
struct mmo_charstatus;
|
||||
|
||||
#define MAX_MAP_SERVERS 30
|
||||
|
||||
#define DEFAULT_AUTOSAVE_INTERVAL 300*1000
|
||||
|
||||
#define msg_config_read(cfgName) char_msg_config_read(cfgName)
|
||||
#define msg_txt(msg_number) char_msg_txt(msg_number)
|
||||
#define do_final_msg() char_do_final_msg()
|
||||
int char_msg_config_read(char *cfgName);
|
||||
const char* char_msg_txt(int msg_number);
|
||||
void char_do_final_msg(void);
|
||||
|
||||
enum {
|
||||
TABLE_INVENTORY,
|
||||
TABLE_CART,
|
||||
@ -36,11 +29,213 @@ enum {
|
||||
TABLE_GUILD_STORAGE,
|
||||
};
|
||||
|
||||
int memitemdata_to_sql(const struct item items[], int max, int id, int tableswitch);
|
||||
struct Schema_Config {
|
||||
int db_use_sqldbs;
|
||||
char db_path[1024];
|
||||
char char_db[DB_NAME_LEN];
|
||||
char scdata_db[DB_NAME_LEN];
|
||||
char skillcooldown_db[DB_NAME_LEN];
|
||||
char cart_db[DB_NAME_LEN];
|
||||
char inventory_db[DB_NAME_LEN];
|
||||
char charlog_db[DB_NAME_LEN];
|
||||
char storage_db[DB_NAME_LEN];
|
||||
char interlog_db[DB_NAME_LEN];
|
||||
char reg_db[DB_NAME_LEN];
|
||||
char skill_db[DB_NAME_LEN];
|
||||
char memo_db[DB_NAME_LEN];
|
||||
char guild_db[DB_NAME_LEN];
|
||||
char guild_alliance_db[DB_NAME_LEN];
|
||||
char guild_castle_db[DB_NAME_LEN];
|
||||
char guild_expulsion_db[DB_NAME_LEN];
|
||||
char guild_member_db[DB_NAME_LEN];
|
||||
char guild_position_db[DB_NAME_LEN];
|
||||
char guild_skill_db[DB_NAME_LEN];
|
||||
char guild_storage_db[DB_NAME_LEN];
|
||||
char party_db[DB_NAME_LEN];
|
||||
char pet_db[DB_NAME_LEN];
|
||||
char mail_db[DB_NAME_LEN]; // MAIL SYSTEM
|
||||
char auction_db[DB_NAME_LEN]; // Auctions System
|
||||
char friend_db[DB_NAME_LEN];
|
||||
char hotkey_db[DB_NAME_LEN];
|
||||
char quest_db[DB_NAME_LEN];
|
||||
char homunculus_db[DB_NAME_LEN];
|
||||
char skill_homunculus_db[DB_NAME_LEN];
|
||||
char mercenary_db[DB_NAME_LEN];
|
||||
char mercenary_owner_db[DB_NAME_LEN];
|
||||
char ragsrvinfo_db[DB_NAME_LEN];
|
||||
char elemental_db[DB_NAME_LEN];
|
||||
char bonus_script_db[DB_NAME_LEN];
|
||||
};
|
||||
extern struct Schema_Config schema_config;
|
||||
|
||||
int mapif_sendall(unsigned char *buf,unsigned int len);
|
||||
int mapif_sendallwos(int fd,unsigned char *buf,unsigned int len);
|
||||
int mapif_send(int fd,unsigned char *buf,unsigned int len);
|
||||
// Pincode system
|
||||
enum pincode_state {
|
||||
PINCODE_OK = 0,
|
||||
PINCODE_ASK,
|
||||
PINCODE_NOTSET,
|
||||
PINCODE_EXPIRED,
|
||||
PINCODE_NEW,
|
||||
PINCODE_PASSED,
|
||||
PINCODE_WRONG,
|
||||
PINCODE_MAXSTATE
|
||||
};
|
||||
struct Pincode_Config {
|
||||
bool pincode_enabled;
|
||||
int pincode_changetime;
|
||||
int pincode_maxtry;
|
||||
bool pincode_force;
|
||||
};
|
||||
struct CharMove_Config {
|
||||
bool char_move_enabled;
|
||||
bool char_movetoused;
|
||||
bool char_moves_unlimited;
|
||||
};
|
||||
struct Char_Config {
|
||||
int char_per_account; //Maximum chars per account (default unlimited) [Sirius]
|
||||
int char_del_level; //From which level u can delete character [Lupus]
|
||||
int char_del_delay; //minimum delay before effectly do the deletion
|
||||
bool name_ignoring_case; // Allow or not identical name for characters but with a different case by [Yor]
|
||||
char unknown_char_name[NAME_LENGTH]; // Name to use when the requested name cannot be determined
|
||||
char char_name_letters[1024]; // list of letters/symbols allowed (or not) in a character name. by [Yor]
|
||||
int char_name_option; // Option to know which letters/symbols are authorised in the name of a character (0: all, 1: only those in char_name_letters, 2: all EXCEPT those in char_name_letters) by [Yor]
|
||||
int char_del_option; // Character deletion type, email = 1, birthdate = 2 (default)
|
||||
};
|
||||
|
||||
#define TRIM_CHARS "\255\xA0\032\t\x0A\x0D " //The following characters are trimmed regardless because they cause confusion and problems on the servers. [Skotlex]
|
||||
struct CharServ_Config {
|
||||
char userid[24];
|
||||
char passwd[24];
|
||||
char server_name[20];
|
||||
char wisp_server_name[NAME_LENGTH];
|
||||
char login_ip_str[128];
|
||||
uint32 login_ip;
|
||||
uint16 login_port;
|
||||
char char_ip_str[128];
|
||||
uint32 char_ip;
|
||||
char bind_ip_str[128];
|
||||
uint32 bind_ip;
|
||||
uint16 char_port;
|
||||
int char_maintenance;
|
||||
bool char_new;
|
||||
int char_new_display;
|
||||
|
||||
struct CharMove_Config charmove_config;
|
||||
struct Char_Config char_config;
|
||||
struct Pincode_Config pincode_config;
|
||||
|
||||
int save_log; // show loading/saving messages
|
||||
int log_char; // loggin char or not [devil]
|
||||
int log_inter; // loggin inter or not [devil]
|
||||
int char_check_db; ///cheking sql-table at begining ?
|
||||
|
||||
struct point start_point; // Initial position the player will spawn on server
|
||||
int console;
|
||||
int max_connect_user;
|
||||
int gm_allow_group;
|
||||
int autosave_interval;
|
||||
int start_zeny;
|
||||
int guild_exp_rate;
|
||||
};
|
||||
extern struct CharServ_Config charserv_config;
|
||||
|
||||
#define MAX_MAP_SERVERS 30 //how many mapserver a char server can handle
|
||||
struct mmo_map_server {
|
||||
int fd;
|
||||
uint32 ip;
|
||||
uint16 port;
|
||||
int users;
|
||||
unsigned short map[MAX_MAP_PER_SERVER];
|
||||
};
|
||||
extern struct mmo_map_server map_server[MAX_MAP_SERVERS];
|
||||
|
||||
#define AUTH_TIMEOUT 30000
|
||||
struct auth_node {
|
||||
int account_id;
|
||||
int char_id;
|
||||
uint32 login_id1;
|
||||
uint32 login_id2;
|
||||
uint32 ip;
|
||||
int sex;
|
||||
time_t expiration_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited)
|
||||
int group_id;
|
||||
unsigned changing_mapservers : 1;
|
||||
uint8 version;
|
||||
};
|
||||
DBMap* char_get_authdb(); // int account_id -> struct auth_node*
|
||||
|
||||
struct online_char_data {
|
||||
int account_id;
|
||||
int 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*
|
||||
|
||||
struct char_session_data {
|
||||
bool auth; // whether the session is authed or not
|
||||
int account_id, login_id1, login_id2, sex;
|
||||
int found_char[MAX_CHARS]; // ids of chars on this account
|
||||
char email[40]; // e-mail (default: a@a.com) by [Yor]
|
||||
time_t expiration_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited)
|
||||
int group_id; // permission
|
||||
uint8 char_slots; // total number of characters that can be created
|
||||
uint8 chars_vip;
|
||||
uint8 chars_billing;
|
||||
uint32 version;
|
||||
uint8 clienttype;
|
||||
char new_name[NAME_LENGTH];
|
||||
char birthdate[10+1]; // YYYY-MM-DD
|
||||
// Pincode system
|
||||
char pincode[PINCODE_LENGTH+1];
|
||||
uint32 pincode_seed;
|
||||
time_t pincode_change;
|
||||
uint16 pincode_try;
|
||||
// Addon system
|
||||
int bank_vault;
|
||||
unsigned int char_moves[MAX_CHARS]; // character moves left
|
||||
uint8 isvip;
|
||||
time_t unban_time[MAX_CHARS];
|
||||
int charblock_timer;
|
||||
};
|
||||
|
||||
|
||||
struct mmo_charstatus;
|
||||
DBMap* char_get_chardb(); // int char_id -> struct mmo_charstatus*
|
||||
|
||||
//Custom limits for the fame lists. [Skotlex]
|
||||
extern int fame_list_size_chemist;
|
||||
extern int fame_list_size_smith;
|
||||
extern int fame_list_size_taekwon;
|
||||
// Char-server-side stored fame lists [DracoRPG]
|
||||
extern struct fame_list smith_fame_list[MAX_FAME_LIST];
|
||||
extern struct fame_list chemist_fame_list[MAX_FAME_LIST];
|
||||
extern struct fame_list taekwon_fame_list[MAX_FAME_LIST];
|
||||
|
||||
#define DEFAULT_AUTOSAVE_INTERVAL 300*1000
|
||||
#define MAX_CHAR_BUF 144 //Max size (for WFIFOHEAD calls)
|
||||
|
||||
int char_search_mapserver(unsigned short map, uint32 ip, uint16 port);
|
||||
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_all_offline(int id);
|
||||
void char_disconnect_player(int 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_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_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);
|
||||
|
||||
@ -48,50 +243,34 @@ 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 request_accreg2(int account_id, int char_id);
|
||||
int save_accreg2(unsigned char* buf, int len);
|
||||
int char_request_accreg2(int account_id, int char_id);
|
||||
int char_save_accreg2(unsigned char* buf, int len);
|
||||
|
||||
extern int char_name_option;
|
||||
extern char char_name_letters[];
|
||||
extern bool char_gm_read;
|
||||
extern int autosave_interval;
|
||||
extern int save_log;
|
||||
extern char db_path[];
|
||||
extern char char_db[256];
|
||||
extern char scdata_db[256];
|
||||
extern char cart_db[256];
|
||||
extern char inventory_db[256];
|
||||
extern char charlog_db[256];
|
||||
extern char storage_db[256];
|
||||
extern char interlog_db[256];
|
||||
extern char reg_db[256];
|
||||
extern char skill_db[256];
|
||||
extern char memo_db[256];
|
||||
extern char guild_db[256];
|
||||
extern char guild_alliance_db[256];
|
||||
extern char guild_castle_db[256];
|
||||
extern char guild_expulsion_db[256];
|
||||
extern char guild_member_db[256];
|
||||
extern char guild_position_db[256];
|
||||
extern char guild_skill_db[256];
|
||||
extern char guild_storage_db[256];
|
||||
extern char party_db[256];
|
||||
extern char pet_db[256];
|
||||
extern char mail_db[256];
|
||||
extern char auction_db[256];
|
||||
extern char quest_db[256];
|
||||
extern char homunculus_db[256];
|
||||
extern char skill_homunculus_db[256];
|
||||
extern char mercenary_db[256];
|
||||
extern char mercenary_owner_db[256];
|
||||
extern char elemental_db[256];
|
||||
extern char ragsrvinfo_db[256];
|
||||
extern char bonus_script_db[256];
|
||||
extern char skillcooldown_db[256];
|
||||
//extern bool char_gm_read;
|
||||
int char_loadName(int char_id, char* name);
|
||||
int char_check_char_name(char * name, char * esc_name);
|
||||
|
||||
extern int db_use_sqldbs; // added for sql item_db read for char server [Valaris]
|
||||
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_read_fame_list(void);
|
||||
|
||||
#if PACKETVER >= 20120307
|
||||
int char_make_new_char_sql(struct char_session_data* sd, char* name_, int slot, int hair_color, int hair_style);
|
||||
#else
|
||||
int char_make_new_char_sql(struct char_session_data* sd, char* name_, int str, int agi, int vit, int int_, int dex, int luk, int slot, int hair_color, int hair_style);
|
||||
#endif
|
||||
|
||||
//For use in packets that depend on an sd being present [Skotlex]
|
||||
#define FIFOSD_CHECK(rest) { if(RFIFOREST(fd) < rest) return 0; if (sd==NULL || !sd->auth) { RFIFOSKIP(fd,rest); return 0; } }
|
||||
|
||||
#define msg_config_read(cfgName) char_msg_config_read(cfgName)
|
||||
#define msg_txt(msg_number) char_msg_txt(msg_number)
|
||||
#define do_final_msg() char_do_final_msg()
|
||||
int char_msg_config_read(char *cfgName);
|
||||
const char* char_msg_txt(int msg_number);
|
||||
void char_do_final_msg(void);
|
||||
|
||||
extern int guild_exp_rate;
|
||||
extern int log_inter;
|
||||
|
||||
#endif /* _CHAR_SQL_H_ */
|
||||
|
1172
src/char/char_clif.c
Normal file
1172
src/char/char_clif.c
Normal file
File diff suppressed because it is too large
Load Diff
67
src/char/char_clif.h
Normal file
67
src/char/char_clif.h
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* File: char_clif.h
|
||||
* Author: lighta
|
||||
*
|
||||
* Created on June 15, 2013, 12:06 PM
|
||||
*/
|
||||
|
||||
#ifndef CHAR_CLIF_H
|
||||
#define CHAR_CLIF_H
|
||||
|
||||
#include "char.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void chclif_moveCharSlotReply( int fd, struct char_session_data* sd, unsigned short index, short reason );
|
||||
int chclif_parse_moveCharSlot( int fd, struct char_session_data* sd);
|
||||
void chclif_pincode_sendstate( int fd, struct char_session_data* sd, enum pincode_state state );
|
||||
int chclif_parse_reqpincode_window(int fd, struct char_session_data* sd);
|
||||
int chclif_parse_pincode_check( int fd, struct char_session_data* sd );
|
||||
int chclif_parse_pincode_change( int fd, struct char_session_data* sd );
|
||||
int chclif_parse_pincode_setnew( int fd, struct char_session_data* sd );
|
||||
|
||||
void chclif_charlist_notify( int fd, struct char_session_data* sd );
|
||||
void chclif_block_character( int fd, struct char_session_data* sd );
|
||||
int chclif_mmo_send006b(int fd, struct char_session_data* sd);
|
||||
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);
|
||||
|
||||
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);
|
||||
int chclif_parse_char_delete2_cancel(int fd, struct char_session_data* sd);
|
||||
|
||||
int chclif_parse_maplogin(int fd);
|
||||
int chclif_parse_reqtoconnect(int fd, struct char_session_data* sd,uint32 ipl);
|
||||
int chclif_parse_req_charlist(int fd, struct char_session_data* sd);
|
||||
int chclif_parse_charselect(int fd, struct char_session_data* sd,uint32 ipl);
|
||||
int chclif_parse_createnewchar(int fd, struct char_session_data* sd,int cmd);
|
||||
int chclif_parse_delchar(int fd,struct char_session_data* sd, int cmd);
|
||||
int chclif_parse_keepalive(int fd);
|
||||
int chclif_parse_reqrename(int fd, struct char_session_data* sd, int cmd);
|
||||
int chclif_parse_ackrename(int fd, struct char_session_data* sd);
|
||||
int chclif_ack_captcha(int fd);
|
||||
int chclif_parse_reqcaptcha(int fd);
|
||||
int chclif_parse_chkcaptcha(int fd);
|
||||
void chclif_block_character( int fd, struct char_session_data* sd);
|
||||
|
||||
int chclif_parse(int fd);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CHAR_CLIF_H */
|
||||
|
99
src/char/char_cnslif.c
Normal file
99
src/char/char_cnslif.c
Normal file
@ -0,0 +1,99 @@
|
||||
// Copyright (c) rAthena Dev Teams - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#include "../common/socket.h"
|
||||
#include "../common/showmsg.h"
|
||||
#include "../common/timer.h"
|
||||
#include "../common/ers.h"
|
||||
#include "../common/cli.h"
|
||||
#include "char.h"
|
||||
#include "char_cnslif.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/*======================================================
|
||||
* Login-Server help option info
|
||||
*------------------------------------------------------*/
|
||||
void display_helpscreen(bool do_exit)
|
||||
{
|
||||
ShowInfo("Usage: %s [options]\n", SERVER_NAME);
|
||||
ShowInfo("\n");
|
||||
ShowInfo("Options:\n");
|
||||
ShowInfo(" -?, -h [--help]\t\tDisplays this help screen.\n");
|
||||
ShowInfo(" -v [--version]\t\tDisplays the server's version.\n");
|
||||
ShowInfo(" --run-once\t\t\tCloses server after loading (testing).\n");
|
||||
ShowInfo(" --char-config <file>\t\tAlternative char-server configuration.\n");
|
||||
ShowInfo(" --lan-config <file>\t\tAlternative lag configuration.\n");
|
||||
ShowInfo(" --inter-config <file>\t\tAlternative inter-server configuration.\n");
|
||||
ShowInfo(" --msg-config <file>\t\tAlternative message configuration.\n");
|
||||
if( do_exit )
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Timered function to check if the console has a new event to be read.
|
||||
* @param tid: timer id
|
||||
* @param tick: tick of execution
|
||||
* @param id: user account id
|
||||
* @param data: unused
|
||||
* @return 0
|
||||
*/
|
||||
int cnslif_console_timer(int tid, unsigned int tick, int id, intptr_t data) {
|
||||
char buf[MAX_CONSOLE_IN]; //max cmd atm is 63+63+63+3+3
|
||||
|
||||
memset(buf,0,MAX_CONSOLE_IN); //clear out buf
|
||||
|
||||
if(cli_hasevent()){
|
||||
if(fgets(buf, MAX_CONSOLE_IN, stdin)==NULL)
|
||||
return -1;
|
||||
else if(strlen(buf)>MIN_CONSOLE_IN)
|
||||
cnslif_parse(buf);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Console Command Parser [Wizputer]
|
||||
int cnslif_parse(const char* buf)
|
||||
{
|
||||
char type[64];
|
||||
char command[64];
|
||||
int n=0;
|
||||
|
||||
if( ( n = sscanf(buf, "%63[^:]:%63[^\n]", type, command) ) < 2 ){
|
||||
if((n = sscanf(buf, "%63[^\n]", type))<1) return -1; //nothing to do no arg
|
||||
}
|
||||
if( n != 2 ){ //end string
|
||||
ShowNotice("Type: '%s'\n",type);
|
||||
command[0] = '\0';
|
||||
}
|
||||
else
|
||||
ShowNotice("Type of command: '%s' || Command: '%s'\n",type,command);
|
||||
|
||||
if( n == 2 && strcmpi("server", type) == 0 ){
|
||||
if( strcmpi("shutdown", command) == 0 || strcmpi("exit", command) == 0 || strcmpi("quit", command) == 0 ){
|
||||
runflag = 0;
|
||||
}
|
||||
else if( strcmpi("alive", command) == 0 || strcmpi("status", command) == 0 )
|
||||
ShowInfo(CL_CYAN"Console: "CL_BOLD"I'm Alive."CL_RESET"\n");
|
||||
}
|
||||
else if( strcmpi("ers_report", type) == 0 ){
|
||||
ers_report();
|
||||
}
|
||||
else if( strcmpi("help", type) == 0 ){
|
||||
ShowInfo("Available commands:\n");
|
||||
ShowInfo("\t server:shutdown => Stops the server.\n");
|
||||
ShowInfo("\t server:alive => Checks if the server is running.\n");
|
||||
ShowInfo("\t ers_report => Displays database usage.\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void do_init_chcnslif(void){
|
||||
if( charserv_config.console ){ //start listening
|
||||
add_timer_func_list(cnslif_console_timer, "cnslif_console_timer");
|
||||
add_timer_interval(gettick()+1000, cnslif_console_timer, 0, 0, 1000); //start in 1s each 1sec
|
||||
}
|
||||
}
|
25
src/char/char_cnslif.h
Normal file
25
src/char/char_cnslif.h
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* File: char_cnslif.h
|
||||
* Author: lighta
|
||||
*
|
||||
* Created on June 15, 2013, 12:07 PM
|
||||
*/
|
||||
|
||||
#ifndef CHAR_CNSLIF_H
|
||||
#define CHAR_CNSLIF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void display_helpscreen(bool do_exit);
|
||||
int cnslif_parse(const char* buf);
|
||||
void do_init_chcnslif(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CHAR_CNSLIF_H */
|
||||
|
774
src/char/char_logif.c
Normal file
774
src/char/char_logif.c
Normal file
@ -0,0 +1,774 @@
|
||||
// Copyright (c) rAthena Dev Teams - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#include "../common/socket.h"
|
||||
#include "../common/timer.h"
|
||||
#include "../common/showmsg.h"
|
||||
#include "../common/sql.h"
|
||||
#include "../common/utils.h"
|
||||
#include "../common/strlib.h"
|
||||
#include "inter.h"
|
||||
#include "int_guild.h"
|
||||
#include "char.h"
|
||||
#include "char_clif.h"
|
||||
#include "char_mapif.h"
|
||||
#include "char_logif.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
//early declaration
|
||||
void chlogif_on_ready(void);
|
||||
void chlogif_on_disconnect(void);
|
||||
|
||||
int chlogif_pincode_notifyLoginPinError( int account_id ){
|
||||
if (login_fd > 0 && session[login_fd] && !session[login_fd]->flag.eof){
|
||||
WFIFOHEAD(login_fd,6);
|
||||
WFIFOW(login_fd,0) = 0x2739;
|
||||
WFIFOL(login_fd,2) = account_id;
|
||||
WFIFOSET(login_fd,6);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int chlogif_pincode_notifyLoginPinUpdate( int account_id, char* pin ){
|
||||
if (login_fd > 0 && session[login_fd] && !session[login_fd]->flag.eof){
|
||||
WFIFOHEAD(login_fd,11);
|
||||
WFIFOW(login_fd,0) = 0x2738;
|
||||
WFIFOL(login_fd,2) = account_id;
|
||||
strncpy( (char*)WFIFOP(login_fd,6), pin, PINCODE_LENGTH+1 );
|
||||
WFIFOSET(login_fd,11);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void chlogif_pincode_start(int fd, struct char_session_data* sd){
|
||||
if( charserv_config.pincode_config.pincode_enabled ){
|
||||
// PIN code system enabled
|
||||
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 );
|
||||
}else{
|
||||
chclif_pincode_sendstate( fd, sd, PINCODE_PASSED );
|
||||
}
|
||||
}else{
|
||||
if( !(charserv_config.pincode_config.pincode_changetime)
|
||||
|| ( sd->pincode_change + charserv_config.pincode_config.pincode_changetime ) > time(NULL) ){
|
||||
DBMap* online_char_db = char_get_onlinedb();
|
||||
struct online_char_data* node = (struct online_char_data*)idb_get( online_char_db, sd->account_id );
|
||||
|
||||
if( node != NULL && node->pincode_success ){
|
||||
// User has already passed the check
|
||||
chclif_pincode_sendstate( fd, sd, PINCODE_PASSED );
|
||||
}else{
|
||||
// Ask user for his PIN code
|
||||
chclif_pincode_sendstate( fd, sd, PINCODE_ASK );
|
||||
}
|
||||
}else{
|
||||
// User hasnt changed his PIN code too long
|
||||
chclif_pincode_sendstate( fd, sd, PINCODE_EXPIRED );
|
||||
}
|
||||
}
|
||||
}else{
|
||||
// PIN code system disabled
|
||||
chclif_pincode_sendstate( fd, sd, PINCODE_OK );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load this character's account id into the 'online accounts' packet
|
||||
* @see DBApply
|
||||
*/
|
||||
static int chlogif_send_acc_tologin_sub(DBKey key, DBData *data, va_list ap) {
|
||||
struct online_char_data* character = db_data2ptr(data);
|
||||
int* i = va_arg(ap, int*);
|
||||
if(character->server > -1) {
|
||||
WFIFOL(login_fd,8+(*i)*4) = character->account_id;
|
||||
(*i)++;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Timered function to send all account_id connected to login-serv
|
||||
* @param tid : Timer id
|
||||
* @param tick : Scheduled tick
|
||||
* @param id : GID linked to that timered call
|
||||
* @param data : data transmited for delayed function
|
||||
* @return
|
||||
*/
|
||||
int chlogif_send_acc_tologin(int tid, unsigned int tick, int id, intptr_t data) {
|
||||
if ( chlogif_isconnected() ){
|
||||
DBMap* online_char_db = char_get_onlinedb();
|
||||
// send account list to login server
|
||||
int users = online_char_db->size(online_char_db);
|
||||
int i = 0;
|
||||
|
||||
WFIFOHEAD(login_fd,8+users*4);
|
||||
WFIFOW(login_fd,0) = 0x272d;
|
||||
online_char_db->foreach(online_char_db, chlogif_send_acc_tologin_sub, &i, users);
|
||||
WFIFOW(login_fd,2) = 8+ i*4;
|
||||
WFIFOL(login_fd,4) = i;
|
||||
WFIFOSET(login_fd,WFIFOW(login_fd,2));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int chlogif_send_usercount(int users){
|
||||
if( login_fd > 0 && session[login_fd] )
|
||||
{
|
||||
// send number of user to login server
|
||||
WFIFOHEAD(login_fd,6);
|
||||
WFIFOW(login_fd,0) = 0x2714;
|
||||
WFIFOL(login_fd,2) = users;
|
||||
WFIFOSET(login_fd,6);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int chlogif_broadcast_user_count(int tid, unsigned int tick, int id, intptr_t data)
|
||||
{
|
||||
uint8 buf[6];
|
||||
int users = char_count_users();
|
||||
|
||||
// only send an update when needed
|
||||
static int prev_users = 0;
|
||||
if( prev_users == users )
|
||||
return 0;
|
||||
prev_users = users;
|
||||
|
||||
if( chlogif_isconnected() )
|
||||
{
|
||||
// send number of user to login server
|
||||
WFIFOHEAD(login_fd,6);
|
||||
WFIFOW(login_fd,0) = 0x2714;
|
||||
WFIFOL(login_fd,2) = users;
|
||||
WFIFOSET(login_fd,6);
|
||||
}
|
||||
|
||||
// send number of players to all map-servers
|
||||
WBUFW(buf,0) = 0x2b00;
|
||||
WBUFL(buf,2) = users;
|
||||
chmapif_sendall(buf,6);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//Send packet forward to login-server for account saving
|
||||
int chlogif_save_accreg2(unsigned char* buf, int len){
|
||||
if (login_fd > 0) {
|
||||
WFIFOHEAD(login_fd,len+4);
|
||||
memcpy(WFIFOP(login_fd,4), buf, len);
|
||||
WFIFOW(login_fd,0) = 0x2728;
|
||||
WFIFOW(login_fd,2) = len+4;
|
||||
WFIFOSET(login_fd,len+4);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int chlogif_request_accreg2(int account_id, int char_id){
|
||||
if (login_fd > 0) {
|
||||
WFIFOHEAD(login_fd,10);
|
||||
WFIFOW(login_fd,0) = 0x272e;
|
||||
WFIFOL(login_fd,2) = account_id;
|
||||
WFIFOL(login_fd,6) = char_id;
|
||||
WFIFOSET(login_fd,10);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int chlogif_send_reqaccdata(int fd, struct char_session_data *sd){
|
||||
//loginif_isconnected
|
||||
if (login_fd > 0) { // request account data
|
||||
// request account data
|
||||
WFIFOHEAD(fd,6);
|
||||
WFIFOW(fd,0) = 0x2716;
|
||||
WFIFOL(fd,2) = sd->account_id;
|
||||
WFIFOSET(fd,6);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int chlogif_send_setacconline(int aid){
|
||||
//loginif_isconnected
|
||||
if (login_fd > 0 && !session[login_fd]->flag.eof){
|
||||
WFIFOHEAD(login_fd,6);
|
||||
WFIFOW(login_fd,0) = 0x272b;
|
||||
WFIFOL(login_fd,2) = aid;
|
||||
WFIFOSET(login_fd,6);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void chlogif_send_setallaccoffline(int fd){
|
||||
WFIFOHEAD(fd,2);
|
||||
WFIFOW(fd,0) = 0x2737;
|
||||
WFIFOSET(fd,2);
|
||||
}
|
||||
|
||||
int chlogif_send_setaccoffline(int fd, int aid){
|
||||
if (chlogif_isconnected()){
|
||||
WFIFOHEAD(fd,6);
|
||||
WFIFOW(fd,0) = 0x272c;
|
||||
WFIFOL(fd,2) = aid;
|
||||
WFIFOSET(fd,6);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int chlogif_parse_ackconnect(int fd, struct char_session_data* sd){
|
||||
if (RFIFOREST(fd) < 3)
|
||||
return 0;
|
||||
|
||||
if (RFIFOB(fd,2)) {
|
||||
//printf("connect login server error : %d\n", RFIFOB(fd,2));
|
||||
ShowError("Can not connect to login-server.\n");
|
||||
ShowError("The server communication passwords (default s1/p1) are probably invalid.\n");
|
||||
ShowError("Also, please make sure your login db has the correct communication username/passwords and the gender of the account is S.\n");
|
||||
ShowError("The communication passwords are set in map_athena.conf and char_athena.conf\n");
|
||||
set_eof(fd);
|
||||
return 0;
|
||||
} else {
|
||||
ShowStatus("Connected to login-server (connection #%d).\n", fd);
|
||||
chlogif_on_ready();
|
||||
}
|
||||
RFIFOSKIP(fd,3);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int chlogif_parse_ackaccreq(int fd, struct char_session_data* sd){
|
||||
if (RFIFOREST(fd) < 25)
|
||||
return 0;
|
||||
{
|
||||
int account_id = RFIFOL(fd,2);
|
||||
uint32 login_id1 = RFIFOL(fd,6);
|
||||
uint32 login_id2 = RFIFOL(fd,10);
|
||||
uint8 sex = RFIFOB(fd,14);
|
||||
uint8 result = RFIFOB(fd,15);
|
||||
int request_id = RFIFOL(fd,16);
|
||||
uint32 version = RFIFOL(fd,20);
|
||||
uint8 clienttype = RFIFOB(fd,24);
|
||||
RFIFOSKIP(fd,25);
|
||||
|
||||
if( session_isActive(request_id) && (sd=(struct char_session_data*)session[request_id]->session_data) &&
|
||||
!sd->auth && sd->account_id == account_id && sd->login_id1 == login_id1 && sd->login_id2 == login_id2 && sd->sex == sex )
|
||||
{
|
||||
int client_fd = request_id;
|
||||
sd->version = version;
|
||||
sd->clienttype = clienttype;
|
||||
if(sd->version != date2version(PACKETVER))
|
||||
ShowWarning("s aid=%d has an incorect version=%d in clientinfo. Server compiled for %d\n",
|
||||
sd->account_id,sd->version,date2version(PACKETVER));
|
||||
|
||||
switch( result )
|
||||
{
|
||||
case 0:// ok
|
||||
char_auth_ok(client_fd, sd);
|
||||
break;
|
||||
case 1:// auth failed
|
||||
WFIFOHEAD(client_fd,3);
|
||||
WFIFOW(client_fd,0) = 0x6c;
|
||||
WFIFOB(client_fd,2) = 0;// rejected from server
|
||||
WFIFOSET(client_fd,3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int chlogif_parse_reqaccdata(int fd, struct char_session_data* sd){
|
||||
int u_fd; //user fd
|
||||
if (RFIFOREST(fd) < 79)
|
||||
return 0;
|
||||
|
||||
// find the authenticated session with this account id
|
||||
ARR_FIND( 0, fd_max, u_fd, session[u_fd] && (sd = (struct char_session_data*)session[u_fd]->session_data) && sd->auth && sd->account_id == RFIFOL(fd,2) );
|
||||
if( u_fd < fd_max )
|
||||
{
|
||||
int server_id;
|
||||
memcpy(sd->email, RFIFOP(fd,6), 40);
|
||||
sd->expiration_time = (time_t)RFIFOL(fd,46);
|
||||
sd->group_id = RFIFOB(fd,50);
|
||||
sd->char_slots = RFIFOB(fd,51);
|
||||
if( sd->char_slots > MAX_CHARS ) {
|
||||
ShowError("Account '%d' `character_slots` column is higher than supported MAX_CHARS (%d), update MAX_CHARS in mmo.h! capping to MAX_CHARS...\n",sd->account_id,sd->char_slots);
|
||||
sd->char_slots = MAX_CHARS;/* cap to maximum */
|
||||
} else if ( !sd->char_slots )/* no value aka 0 in sql */
|
||||
sd->char_slots = MIN_CHARS;/* cap to minimum */
|
||||
safestrncpy(sd->birthdate, (const char*)RFIFOP(fd,52), sizeof(sd->birthdate));
|
||||
safestrncpy(sd->pincode, (const char*)RFIFOP(fd,63), sizeof(sd->pincode));
|
||||
sd->pincode_change = (time_t)RFIFOL(fd,68);
|
||||
sd->bank_vault = RFIFOL(fd,72);
|
||||
sd->isvip = RFIFOB(fd,76);
|
||||
sd->chars_vip = RFIFOB(fd,77);
|
||||
sd->chars_billing = RFIFOB(fd,78);
|
||||
ARR_FIND( 0, ARRAYLENGTH(map_server), server_id, map_server[server_id].fd > 0 && map_server[server_id].map[0] );
|
||||
// continued from char_auth_ok...
|
||||
if( server_id == ARRAYLENGTH(map_server) || //server not online, bugreport:2359
|
||||
(charserv_config.max_connect_user == 0 && sd->group_id != charserv_config.gm_allow_group) ||
|
||||
( charserv_config.max_connect_user > 0 && char_count_users() >= charserv_config.max_connect_user && sd->group_id != charserv_config.gm_allow_group ) ) {
|
||||
// refuse connection (over populated)
|
||||
WFIFOHEAD(u_fd,3);
|
||||
WFIFOW(u_fd,0) = 0x6c;
|
||||
WFIFOW(u_fd,2) = 0;
|
||||
WFIFOSET(u_fd,3);
|
||||
} else {
|
||||
// send characters to player
|
||||
chclif_mmo_char_send(u_fd, sd);
|
||||
if(sd->version >= date2version(20110309)){
|
||||
ShowInfo("Asking to start pincode\n");
|
||||
chlogif_pincode_start(u_fd,sd);
|
||||
}
|
||||
}
|
||||
}
|
||||
RFIFOSKIP(fd,79);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int chlogif_parse_keepalive(int fd, struct char_session_data* sd){
|
||||
if (RFIFOREST(fd) < 2)
|
||||
return 0;
|
||||
RFIFOSKIP(fd,2);
|
||||
session[fd]->flag.ping = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int chlogif_parse_ackchangesex(int fd, struct char_session_data* sd){
|
||||
if (RFIFOREST(fd) < 7)
|
||||
return 0;
|
||||
{
|
||||
unsigned char buf[7];
|
||||
int i;
|
||||
|
||||
int acc = RFIFOL(fd,2);
|
||||
int sex = RFIFOB(fd,6);
|
||||
RFIFOSKIP(fd,7);
|
||||
|
||||
if( acc > 0 )
|
||||
{// TODO: Is this even possible?
|
||||
int char_id[MAX_CHARS];
|
||||
int class_[MAX_CHARS];
|
||||
int guild_id[MAX_CHARS];
|
||||
int num;
|
||||
char* data;
|
||||
DBMap* auth_db = char_get_authdb();
|
||||
|
||||
struct auth_node* node = (struct auth_node*)idb_get(auth_db, acc);
|
||||
if( node != NULL )
|
||||
node->sex = sex;
|
||||
|
||||
// get characters
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `char_id`,`class`,`guild_id` FROM `%s` WHERE `account_id` = '%d'", schema_config.char_db, acc) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
for( i = 0; i < MAX_CHARS && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i )
|
||||
{
|
||||
Sql_GetData(sql_handle, 0, &data, NULL); char_id[i] = atoi(data);
|
||||
Sql_GetData(sql_handle, 1, &data, NULL); class_[i] = atoi(data);
|
||||
Sql_GetData(sql_handle, 2, &data, NULL); guild_id[i] = atoi(data);
|
||||
}
|
||||
num = i;
|
||||
for( i = 0; i < num; ++i )
|
||||
{
|
||||
if( class_[i] == JOB_BARD || class_[i] == JOB_DANCER ||
|
||||
class_[i] == JOB_CLOWN || class_[i] == JOB_GYPSY ||
|
||||
class_[i] == JOB_BABY_BARD || class_[i] == JOB_BABY_DANCER ||
|
||||
class_[i] == JOB_MINSTREL || class_[i] == JOB_WANDERER ||
|
||||
class_[i] == JOB_MINSTREL_T || class_[i] == JOB_WANDERER_T ||
|
||||
class_[i] == JOB_BABY_MINSTREL || class_[i] == JOB_BABY_WANDERER ||
|
||||
class_[i] == JOB_KAGEROU || class_[i] == JOB_OBORO )
|
||||
{
|
||||
// job modification
|
||||
if( class_[i] == JOB_BARD || class_[i] == JOB_DANCER )
|
||||
class_[i] = (sex ? JOB_BARD : JOB_DANCER);
|
||||
else if( class_[i] == JOB_CLOWN || class_[i] == JOB_GYPSY )
|
||||
class_[i] = (sex ? JOB_CLOWN : JOB_GYPSY);
|
||||
else if( class_[i] == JOB_BABY_BARD || class_[i] == JOB_BABY_DANCER )
|
||||
class_[i] = (sex ? JOB_BABY_BARD : JOB_BABY_DANCER);
|
||||
else if( class_[i] == JOB_MINSTREL || class_[i] == JOB_WANDERER )
|
||||
class_[i] = (sex ? JOB_MINSTREL : JOB_WANDERER);
|
||||
else if( class_[i] == JOB_MINSTREL_T || class_[i] == JOB_WANDERER_T )
|
||||
class_[i] = (sex ? JOB_MINSTREL_T : JOB_WANDERER_T);
|
||||
else if( class_[i] == JOB_BABY_MINSTREL || class_[i] == JOB_BABY_WANDERER )
|
||||
class_[i] = (sex ? JOB_BABY_MINSTREL : JOB_BABY_WANDERER);
|
||||
else if( class_[i] == JOB_KAGEROU || class_[i] == JOB_OBORO )
|
||||
class_[i] = (sex ? JOB_KAGEROU : JOB_OBORO);
|
||||
}
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `class`='%d', `weapon`='0', `shield`='0', `head_top`='0', `head_mid`='0', `head_bottom`='0' WHERE `char_id`='%d'", schema_config.char_db, class_[i], char_id[i]) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
if( guild_id[i] )// If there is a guild, update the guild_member data [Skotlex]
|
||||
inter_guild_sex_changed(guild_id[i], acc, char_id[i], sex);
|
||||
}
|
||||
Sql_FreeResult(sql_handle);
|
||||
|
||||
// disconnect player if online on char-server
|
||||
char_disconnect_player(acc);
|
||||
}
|
||||
|
||||
// notify all mapservers about this change
|
||||
WBUFW(buf,0) = 0x2b0d;
|
||||
WBUFL(buf,2) = acc;
|
||||
WBUFB(buf,6) = sex;
|
||||
chmapif_sendall(buf, 7);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int chlogif_parse_ackacc2req(int fd, struct char_session_data* sd){
|
||||
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
|
||||
return 0;
|
||||
|
||||
{ //Receive account_reg2 registry, forward to map servers.
|
||||
unsigned char buf[13+ACCOUNT_REG2_NUM*sizeof(struct global_reg)];
|
||||
memcpy(buf,RFIFOP(fd,0), RFIFOW(fd,2));
|
||||
WBUFW(buf,0) = 0x3804; //Map server can now receive all kinds of reg values with the same packet. [Skotlex]
|
||||
chmapif_sendall(buf, WBUFW(buf,2));
|
||||
RFIFOSKIP(fd, RFIFOW(fd,2));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int chlogif_parse_accbannotification(int fd, struct char_session_data* sd){
|
||||
if (RFIFOREST(fd) < 11)
|
||||
return 0;
|
||||
|
||||
{ // send to all map-servers to disconnect the player
|
||||
unsigned char buf[11];
|
||||
WBUFW(buf,0) = 0x2b14;
|
||||
WBUFL(buf,2) = RFIFOL(fd,2);
|
||||
WBUFB(buf,6) = RFIFOB(fd,6); // 0: change of statut, 1: ban
|
||||
WBUFL(buf,7) = RFIFOL(fd,7); // status or final date of a banishment
|
||||
chmapif_sendall(buf, 11);
|
||||
}
|
||||
// disconnect player if online on char-server
|
||||
char_disconnect_player(RFIFOL(fd,2));
|
||||
RFIFOSKIP(fd,11);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int chlogif_parse_askkick(int fd, struct char_session_data* sd){
|
||||
if (RFIFOREST(fd) < 6)
|
||||
return 0;
|
||||
{
|
||||
DBMap* online_char_db = char_get_onlinedb();
|
||||
DBMap* auth_db = char_get_authdb();
|
||||
int aid = RFIFOL(fd,2);
|
||||
struct online_char_data* character = (struct online_char_data*)idb_get(online_char_db, aid);
|
||||
RFIFOSKIP(fd,6);
|
||||
if( character != NULL )
|
||||
{// account is already marked as online!
|
||||
if( character->server > -1 )
|
||||
{ //Kick it from the map server it is on.
|
||||
mapif_disconnectplayer(map_server[character->server].fd, character->account_id, character->char_id, 2);
|
||||
if (character->waiting_disconnect == INVALID_TIMER)
|
||||
character->waiting_disconnect = add_timer(gettick()+AUTH_TIMEOUT, char_chardb_waiting_disconnect, character->account_id, 0);
|
||||
}
|
||||
else
|
||||
{// Manual kick from char server.
|
||||
struct char_session_data *tsd;
|
||||
int i;
|
||||
ARR_FIND( 0, fd_max, i, session[i] && (tsd = (struct char_session_data*)session[i]->session_data) && tsd->account_id == aid );
|
||||
if( i < fd_max )
|
||||
{
|
||||
chclif_send_auth_result(i,2); //Send "Someone has already logged in with this id"
|
||||
set_eof(i);
|
||||
}
|
||||
else // still moving to the map-server
|
||||
char_set_char_offline(-1, aid);
|
||||
}
|
||||
}
|
||||
idb_remove(auth_db, aid);// reject auth attempts from map-server
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int chlogif_parse_updip(int fd, struct char_session_data* sd){
|
||||
unsigned char buf[2];
|
||||
uint32 new_ip = 0;
|
||||
|
||||
WBUFW(buf,0) = 0x2b1e;
|
||||
chmapif_sendall(buf, 2);
|
||||
|
||||
new_ip = host2ip(charserv_config.login_ip_str);
|
||||
if (new_ip && new_ip != charserv_config.login_ip)
|
||||
charserv_config.login_ip = new_ip; //Update login ip, too.
|
||||
|
||||
new_ip = host2ip(charserv_config.char_ip_str);
|
||||
if (new_ip && new_ip != charserv_config.char_ip)
|
||||
{ //Update ip.
|
||||
charserv_config.char_ip = new_ip;
|
||||
ShowInfo("Updating IP for [%s].\n", charserv_config.char_ip_str);
|
||||
// notify login server about the change
|
||||
WFIFOHEAD(fd,6);
|
||||
WFIFOW(fd,0) = 0x2736;
|
||||
WFIFOL(fd,2) = htonl(charserv_config.char_ip);
|
||||
WFIFOSET(fd,6);
|
||||
}
|
||||
|
||||
RFIFOSKIP(fd,2);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send to login-serv the request of banking operation from map
|
||||
* HA 0x2740<aid>L <type>B <data>L
|
||||
* @param account_id
|
||||
* @param type : 0 = select, 1 = update
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
int chlogif_BankingReq(int32 account_id, int8 type, int32 data){
|
||||
loginif_check(-1);
|
||||
|
||||
WFIFOHEAD(login_fd,11);
|
||||
WFIFOW(login_fd,0) = 0x2740;
|
||||
WFIFOL(login_fd,2) = account_id;
|
||||
WFIFOB(login_fd,6) = type;
|
||||
WFIFOL(login_fd,7) = data;
|
||||
WFIFOSET(login_fd,11);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Received the banking data from login and transmit it to all map-serv
|
||||
* AH 0x2741<aid>L <bank_vault>L <not_fw>B
|
||||
* HZ 0x2b29 <aid>L <bank_vault>L
|
||||
*/
|
||||
int chlogif_parse_BankingAck(int fd){
|
||||
if (RFIFOREST(fd) < 11)
|
||||
return 0;
|
||||
else {
|
||||
uint32 aid = RFIFOL(fd,2);
|
||||
int32 bank_vault = RFIFOL(fd,6);
|
||||
char not_fw = RFIFOB(fd,10);
|
||||
RFIFOSKIP(fd,11);
|
||||
|
||||
if(not_fw==0) chmapif_BankingAck(aid, bank_vault);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* AH 0x2743
|
||||
* We received the info from login-serv, transmit it to map
|
||||
*/
|
||||
int chlogif_parse_vipack(int fd) {
|
||||
#ifdef VIP_ENABLE
|
||||
if (RFIFOREST(fd) < 20)
|
||||
return 0;
|
||||
else {
|
||||
uint32 aid = RFIFOL(fd,2); //aid
|
||||
uint32 vip_time = RFIFOL(fd,6); //vip_time
|
||||
uint8 isvip = RFIFOB(fd,10); //isvip
|
||||
uint32 groupid = RFIFOL(fd,11); //new group id
|
||||
uint8 isgm = RFIFOB(fd,15); //isgm
|
||||
int mapfd = RFIFOL(fd,16); //link to mapserv for ack
|
||||
RFIFOSKIP(fd,20);
|
||||
mapif_vipack(mapfd,aid,vip_time,isvip,isgm,groupid);
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* HZ 0x2b2b
|
||||
* Request vip data from loginserv
|
||||
* @param aid : account_id to request the vip data
|
||||
* @param type : &2 define new duration, &1 load info
|
||||
* @param add_vip_time : tick to add to vip timestamp
|
||||
* @param mapfd: link to mapserv for ack
|
||||
* @return 0 if success
|
||||
*/
|
||||
int chlogif_reqvipdata(uint32 aid, uint8 type, int32 timediff, int mapfd) {
|
||||
loginif_check(-1);
|
||||
#ifdef VIP_ENABLE
|
||||
WFIFOHEAD(login_fd,15);
|
||||
WFIFOW(login_fd,0) = 0x2742;
|
||||
WFIFOL(login_fd,2) = aid; //aid
|
||||
WFIFOB(login_fd,6) = type; //type
|
||||
WFIFOL(login_fd,7) = timediff; //req_inc_duration
|
||||
WFIFOL(login_fd,11) = mapfd; //req_inc_duration
|
||||
WFIFOSET(login_fd,15);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int chlogif_parse(int fd) {
|
||||
struct char_session_data* sd = NULL;
|
||||
|
||||
// only process data from the login-server
|
||||
if( fd != login_fd ) {
|
||||
ShowDebug("parse_fromlogin: Disconnecting invalid session #%d (is not the login-server)\n", fd);
|
||||
do_close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( session[fd]->flag.eof ) {
|
||||
do_close(fd);
|
||||
login_fd = -1;
|
||||
chlogif_on_disconnect();
|
||||
return 0;
|
||||
} else if ( session[fd]->flag.ping ) {/* we've reached stall time */
|
||||
if( DIFF_TICK(last_tick, session[fd]->rdata_tick) > (stall_time * 2) ) {/* we can't wait any longer */
|
||||
set_eof(fd);
|
||||
return 0;
|
||||
} else if( session[fd]->flag.ping != 2 ) { /* we haven't sent ping out yet */
|
||||
WFIFOHEAD(fd,2);// sends a ping packet to login server (will receive pong 0x2718)
|
||||
WFIFOW(fd,0) = 0x2719;
|
||||
WFIFOSET(fd,2);
|
||||
|
||||
session[fd]->flag.ping = 2;
|
||||
}
|
||||
}
|
||||
|
||||
sd = (struct char_session_data*)session[fd]->session_data;
|
||||
|
||||
while(RFIFOREST(fd) >= 2) {
|
||||
int next=1;
|
||||
uint16 command = RFIFOW(fd,0);
|
||||
switch( command )
|
||||
{
|
||||
case 0x2741: next=chlogif_parse_BankingAck(fd); break;
|
||||
case 0x2743: next=chlogif_parse_vipack(fd); break;
|
||||
// acknowledgement of connect-to-loginserver request
|
||||
case 0x2711: next=chlogif_parse_ackconnect(fd,sd); break;
|
||||
// acknowledgement of account authentication request
|
||||
case 0x2713: next=chlogif_parse_ackaccreq(fd, sd); break;
|
||||
// account data
|
||||
case 0x2717: next=chlogif_parse_reqaccdata(fd, sd); break;
|
||||
// login-server alive packet
|
||||
case 0x2718: next=chlogif_parse_keepalive(fd, sd); break;
|
||||
// changesex reply
|
||||
case 0x2723: next=chlogif_parse_ackchangesex(fd, sd); break;
|
||||
// reply to an account_reg2 registry request
|
||||
case 0x2729: next=chlogif_parse_ackacc2req(fd, sd); break;
|
||||
// State change of account/ban notification (from login-server)
|
||||
case 0x2731: next=chlogif_parse_accbannotification(fd, sd); break;
|
||||
// Login server request to kick a character out. [Skotlex]
|
||||
case 0x2734: next=chlogif_parse_askkick(fd,sd); break;
|
||||
// ip address update signal from login server
|
||||
case 0x2735: next=chlogif_parse_updip(fd,sd); break;
|
||||
default:
|
||||
ShowError("Unknown packet 0x%04x received from login-server, disconnecting.\n", command);
|
||||
set_eof(fd);
|
||||
return 0;
|
||||
}
|
||||
if(next==0) return 0; //do not parse next data
|
||||
}
|
||||
|
||||
RFIFOFLUSH(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int chlogif_check_connect_logserver(int tid, unsigned int tick, int id, intptr_t data) {
|
||||
if (login_fd > 0 && session[login_fd] != NULL)
|
||||
return 0;
|
||||
|
||||
ShowInfo("Attempt to connect to login-server...\n");
|
||||
login_fd = make_connection(charserv_config.login_ip, charserv_config.login_port, false,10);
|
||||
if (login_fd == -1)
|
||||
{ //Try again later. [Skotlex]
|
||||
login_fd = 0;
|
||||
return 0;
|
||||
}
|
||||
session[login_fd]->func_parse = chlogif_parse;
|
||||
session[login_fd]->flag.server = 1;
|
||||
realloc_fifo(login_fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
|
||||
|
||||
WFIFOHEAD(login_fd,86);
|
||||
WFIFOW(login_fd,0) = 0x2710;
|
||||
memcpy(WFIFOP(login_fd,2), charserv_config.userid, 24);
|
||||
memcpy(WFIFOP(login_fd,26), charserv_config.passwd, 24);
|
||||
WFIFOL(login_fd,50) = 0;
|
||||
WFIFOL(login_fd,54) = htonl(charserv_config.char_ip);
|
||||
WFIFOW(login_fd,58) = htons(charserv_config.char_port);
|
||||
memcpy(WFIFOP(login_fd,60), charserv_config.server_name, 20);
|
||||
WFIFOW(login_fd,80) = 0;
|
||||
WFIFOW(login_fd,82) = charserv_config.char_maintenance;
|
||||
WFIFOW(login_fd,84) = charserv_config.char_new_display; //only display (New) if they want to [Kevin]
|
||||
WFIFOSET(login_fd,86);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int chlogif_isconnected(){
|
||||
return (login_fd > 0 && session[login_fd] && !session[login_fd]->flag.eof);
|
||||
}
|
||||
|
||||
void do_init_chlogif(void) {
|
||||
// establish char-login connection if not present
|
||||
add_timer_func_list(chlogif_check_connect_logserver, "check_connect_login_server");
|
||||
add_timer_interval(gettick() + 1000, chlogif_check_connect_logserver, 0, 0, 10 * 1000);
|
||||
|
||||
// send a list of all online account IDs to login server
|
||||
add_timer_func_list(chlogif_send_acc_tologin, "send_accounts_tologin");
|
||||
add_timer_interval(gettick() + 1000, chlogif_send_acc_tologin, 0, 0, 3600 * 1000); //Sync online accounts every hour
|
||||
}
|
||||
|
||||
/// Resets all the data.
|
||||
void chlogif_reset(void){
|
||||
int id;
|
||||
// TODO kick everyone out and reset everything or wait for connect and try to reaquire locks [FlavioJS]
|
||||
for( id = 0; id < ARRAYLENGTH(map_server); ++id )
|
||||
chmapif_server_reset(id);
|
||||
flush_fifos();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/// Checks the conditions for the server to stop.
|
||||
/// Releases the cookie when all characters are saved.
|
||||
/// If all the conditions are met, it stops the core loop.
|
||||
void chlogif_check_shutdown(void)
|
||||
{
|
||||
if( runflag != CHARSERVER_ST_SHUTDOWN )
|
||||
return;
|
||||
runflag = CORE_ST_STOP;
|
||||
}
|
||||
|
||||
/// Called when the connection to Login Server is disconnected.
|
||||
void chlogif_on_disconnect(void){
|
||||
ShowWarning("Connection to Login Server lost.\n\n");
|
||||
}
|
||||
|
||||
/// Called when all the connection steps are completed.
|
||||
void chlogif_on_ready(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
chlogif_check_shutdown();
|
||||
|
||||
//Send online accounts to login server.
|
||||
chlogif_send_acc_tologin(INVALID_TIMER, gettick(), 0, 0);
|
||||
|
||||
// if no map-server already connected, display a message...
|
||||
ARR_FIND( 0, ARRAYLENGTH(map_server), i, map_server[i].fd > 0 && map_server[i].map[0] );
|
||||
if( i == ARRAYLENGTH(map_server) )
|
||||
ShowStatus("Awaiting maps from map-server.\n");
|
||||
}
|
||||
|
||||
void do_final_chlogif(void)
|
||||
{
|
||||
if( login_fd != -1 )
|
||||
{
|
||||
do_close(login_fd);
|
||||
login_fd = -1;
|
||||
}
|
||||
}
|
63
src/char/char_logif.h
Normal file
63
src/char/char_logif.h
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* File: char_logif.h
|
||||
* Author: lighta
|
||||
*
|
||||
* Created on June 15, 2013, 12:05 PM
|
||||
*/
|
||||
|
||||
#ifndef CHAR_LOGIF_H
|
||||
#define CHAR_LOGIF_H
|
||||
|
||||
#include "char.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int chlogif_pincode_notifyLoginPinError( int account_id );
|
||||
int chlogif_pincode_notifyLoginPinUpdate( int account_id, char* pin );
|
||||
void chlogif_pincode_start(int fd, struct char_session_data* sd);
|
||||
int chlogif_send_acc_tologin(int tid, unsigned int tick, int id, intptr_t data);
|
||||
int chlogif_broadcast_user_count(int tid, unsigned int tick, int id, intptr_t data);
|
||||
int chlogif_send_usercount(int users);
|
||||
int chlogif_save_accreg2(unsigned char* buf, int len);
|
||||
int chlogif_request_accreg2(int account_id, int char_id);
|
||||
int chlogif_send_reqaccdata(int fd, struct char_session_data *sd);
|
||||
int chlogif_send_setacconline(int aid);
|
||||
void chlogif_send_setallaccoffline(int fd);
|
||||
int chlogif_send_setaccoffline(int fd, int aid);
|
||||
int chlogif_parse_ackconnect(int fd, struct char_session_data* sd);
|
||||
int chlogif_parse_ackaccreq(int fd, struct char_session_data* sd);
|
||||
int chlogif_parse_reqaccdata(int fd, struct char_session_data* sd);
|
||||
int chlogif_parse_keepalive(int fd, struct char_session_data* sd);
|
||||
int chlogif_parse_ackchangesex(int fd, struct char_session_data* sd);
|
||||
int chlogif_parse_ackacc2req(int fd, struct char_session_data* sd);
|
||||
int chlogif_parse_accbannotification(int fd, struct char_session_data* sd);
|
||||
int chlogif_parse_askkick(int fd, struct char_session_data* sd);
|
||||
int chlogif_parse_updip(int fd, struct char_session_data* sd);
|
||||
|
||||
int chlogif_BankingReq(int32 account_id, int8 type, int32 data);
|
||||
int chlogif_parse_BankingAck(int fd);
|
||||
int chlogif_parse_vipack(int fd);
|
||||
int chlogif_reqvipdata(uint32 aid, uint8 type, int32 timediff, int mapfd);
|
||||
|
||||
int chlogif_parse(int fd);
|
||||
|
||||
int chlogif_isconnected();
|
||||
int chlogif_check_connect_logserver(int tid, unsigned int tick, int id, intptr_t data);
|
||||
void do_init_chlogif(void);
|
||||
void chlogif_reset(void);
|
||||
void chlogif_check_shutdown(void);
|
||||
void chlogif_on_disconnect(void);
|
||||
void chlogif_on_ready(void);
|
||||
void do_final_chlogif(void);
|
||||
|
||||
|
||||
#define loginif_check(a) { if(!chlogif_isconnected()) return a; }
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CHAR_LOGIF_H */
|
||||
|
1501
src/char/char_mapif.c
Normal file
1501
src/char/char_mapif.c
Normal file
File diff suppressed because it is too large
Load Diff
73
src/char/char_mapif.h
Normal file
73
src/char/char_mapif.h
Normal file
@ -0,0 +1,73 @@
|
||||
/**
|
||||
* @file char_mapif.h
|
||||
* Module purpose is to handle incoming and outgoing requests with map-server.
|
||||
* Licensed under GNU GPL.
|
||||
* For more information, see LICENCE in the main folder.
|
||||
* @author Athena Dev Teams originally in login.c
|
||||
* @author rAthena Dev Team
|
||||
*/
|
||||
|
||||
|
||||
#ifndef CHAR_MAPIF_H
|
||||
#define CHAR_MAPIF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int chmapif_sendall(unsigned char *buf, unsigned int len);
|
||||
int chmapif_sendallwos(int sfd, unsigned char *buf, unsigned int len);
|
||||
int chmapif_send(int fd, unsigned char *buf, unsigned int len);
|
||||
int chmapif_send_fame_list(int fd);
|
||||
void chmapif_update_fame_list(int type, int index, int fame);
|
||||
void chmapif_sendall_playercount(int users);
|
||||
int chmapif_parse_getmapname(int fd, int id);
|
||||
int chmapif_parse_askscdata(int fd);
|
||||
int chmapif_parse_getusercount(int fd, int id);
|
||||
int chmapif_parse_regmapuser(int fd, int id);
|
||||
int chmapif_parse_reqsavechar(int fd, int id);
|
||||
int chmapif_parse_authok(int fd);
|
||||
int chmapif_parse_req_saveskillcooldown(int fd);
|
||||
int chmapif_parse_req_skillcooldown(int fd);
|
||||
int chmapif_parse_reqchangemapserv(int fd);
|
||||
int chmapif_parse_askrmfriend(int fd);
|
||||
int chmapif_parse_reqcharname(int fd);
|
||||
int chmapif_parse_reqnewemail(int fd);
|
||||
int chmapif_parse_fwlog_changestatus(int fd);
|
||||
int chmapif_parse_updfamelist(int fd);
|
||||
void chmapif_send_ackdivorce(int partner_id1, int partner_id2);
|
||||
int chmapif_parse_reqdivorce(int fd);
|
||||
int chmapif_parse_updmapinfo(int fd);
|
||||
int chmapif_parse_setcharoffline(int fd);
|
||||
int chmapif_parse_setalloffline(int fd, int id);
|
||||
int chmapif_parse_setcharonline(int fd, int id);
|
||||
int chmapif_parse_reqfamelist(int fd);
|
||||
int chmapif_parse_save_scdata(int fd);
|
||||
int chmapif_parse_keepalive(int fd);
|
||||
int chmapif_parse_reqauth(int fd, int id);
|
||||
int chmapif_parse_updmapip(int fd, int id);
|
||||
int chmapif_parse_fw_configstats(int fd);
|
||||
|
||||
int chmapif_BankingAck(int32 account_id, int32 bank_vault);
|
||||
int chmapif_vipack(int mapfd, uint32 aid, uint32 vip_time, uint8 isvip, uint8 isgm, uint32 groupid);
|
||||
int chmapif_parse_reqcharban(int fd);
|
||||
int chmapif_parse_reqcharunban(int fd);
|
||||
int chmapif_bonus_script_get(int fd);
|
||||
int chmapif_bonus_script_save(int fd);
|
||||
|
||||
int chmapif_parse(int fd);
|
||||
int chmapif_init(int fd);
|
||||
void chmapif_server_init(int id);
|
||||
void chmapif_server_destroy(int id);
|
||||
void do_init_chmapif(void);
|
||||
void chmapif_server_reset(int id);
|
||||
void chmapif_on_disconnect(int id);
|
||||
void do_final_chmapif(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CHAR_MAPIF_H */
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "../common/sql.h"
|
||||
#include "../common/timer.h"
|
||||
#include "char.h"
|
||||
#include "char_mapif.h"
|
||||
#include "inter.h"
|
||||
#include "int_mail.h"
|
||||
#include "int_auction.h"
|
||||
@ -50,7 +51,7 @@ void auction_save(struct auction_data *auction)
|
||||
|
||||
StringBuf_Init(&buf);
|
||||
StringBuf_Printf(&buf, "UPDATE `%s` SET `seller_id` = '%d', `seller_name` = ?, `buyer_id` = '%d', `buyer_name` = ?, `price` = '%d', `buynow` = '%d', `hours` = '%d', `timestamp` = '%lu', `nameid` = '%d', `item_name` = ?, `type` = '%d', `refine` = '%d', `attribute` = '%d'",
|
||||
auction_db, auction->seller_id, auction->buyer_id, auction->price, auction->buynow, auction->hours, (unsigned long)auction->timestamp, auction->item.nameid, auction->type, auction->item.refine, auction->item.attribute);
|
||||
schema_config.auction_db, auction->seller_id, auction->buyer_id, auction->price, auction->buynow, auction->hours, (unsigned long)auction->timestamp, auction->item.nameid, auction->type, auction->item.refine, auction->item.attribute);
|
||||
for( j = 0; j < MAX_SLOTS; j++ )
|
||||
StringBuf_Printf(&buf, ", `card%d` = '%d'", j, auction->item.card[j]);
|
||||
StringBuf_Printf(&buf, " WHERE `auction_id` = '%d'", auction->auction_id);
|
||||
@ -81,7 +82,7 @@ unsigned int auction_create(struct auction_data *auction)
|
||||
auction->timestamp = time(NULL) + (auction->hours * 3600);
|
||||
|
||||
StringBuf_Init(&buf);
|
||||
StringBuf_Printf(&buf, "INSERT INTO `%s` (`seller_id`,`seller_name`,`buyer_id`,`buyer_name`,`price`,`buynow`,`hours`,`timestamp`,`nameid`,`item_name`,`type`,`refine`,`attribute`,`unique_id`", auction_db);
|
||||
StringBuf_Printf(&buf, "INSERT INTO `%s` (`seller_id`,`seller_name`,`buyer_id`,`buyer_name`,`price`,`buynow`,`hours`,`timestamp`,`nameid`,`item_name`,`type`,`refine`,`attribute`,`unique_id`", schema_config.auction_db);
|
||||
for( j = 0; j < MAX_SLOTS; j++ )
|
||||
StringBuf_Printf(&buf, ",`card%d`", j);
|
||||
StringBuf_Printf(&buf, ") VALUES ('%d',?,'%d',?,'%d','%d','%d','%lu','%d',?,'%d','%d','%d','%"PRIu64"'",
|
||||
@ -135,7 +136,7 @@ static void mapif_Auction_message(int char_id, unsigned char result)
|
||||
WBUFW(buf,0) = 0x3854;
|
||||
WBUFL(buf,2) = char_id;
|
||||
WBUFL(buf,6) = result;
|
||||
mapif_sendall(buf,7);
|
||||
chmapif_sendall(buf,7);
|
||||
}
|
||||
|
||||
static int auction_end_timer(int tid, unsigned int tick, int id, intptr_t data)
|
||||
@ -165,7 +166,7 @@ void auction_delete(struct auction_data *auction)
|
||||
{
|
||||
unsigned int auction_id = auction->auction_id;
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `auction_id` = '%d'", auction_db, auction_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `auction_id` = '%d'", schema_config.auction_db, auction_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
if( auction->auction_end_timer != INVALID_TIMER )
|
||||
@ -187,7 +188,7 @@ void inter_auctions_fromsql(void)
|
||||
"`price`,`buynow`,`hours`,`timestamp`,`nameid`,`item_name`,`type`,`refine`,`attribute`,`unique_id`");
|
||||
for( i = 0; i < MAX_SLOTS; i++ )
|
||||
StringBuf_Printf(&buf, ",`card%d`", i);
|
||||
StringBuf_Printf(&buf, " FROM `%s` ORDER BY `auction_id` DESC", auction_db);
|
||||
StringBuf_Printf(&buf, " FROM `%s` ORDER BY `auction_id` DESC", schema_config.auction_db);
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, StringBuf_Value(&buf)) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
@ -17,12 +17,12 @@
|
||||
|
||||
bool mapif_elemental_save(struct s_elemental* ele) {
|
||||
bool flag = true;
|
||||
|
||||
|
||||
if( ele->elemental_id == 0 ) { // Create new DB entry
|
||||
if( SQL_ERROR == Sql_Query(sql_handle,
|
||||
"INSERT INTO `%s` (`char_id`,`class`,`mode`,`hp`,`sp`,`max_hp`,`max_sp`,`atk1`,`atk2`,`matk`,`aspd`,`def`,`mdef`,`flee`,`hit`,`life_time`)"
|
||||
"VALUES ('%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%u')",
|
||||
elemental_db, ele->char_id, ele->class_, ele->mode, ele->hp, ele->sp, ele->max_hp, ele->max_sp, ele->atk, ele->atk2, ele->matk, ele->amotion, ele->def, ele->mdef, ele->flee, ele->hit, ele->life_time) )
|
||||
schema_config.elemental_db, ele->char_id, ele->class_, ele->mode, ele->hp, ele->sp, ele->max_hp, ele->max_sp, ele->atk, ele->atk2, ele->matk, ele->amotion, ele->def, ele->mdef, ele->flee, ele->hit, ele->life_time) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
flag = false;
|
||||
@ -32,7 +32,7 @@ bool mapif_elemental_save(struct s_elemental* ele) {
|
||||
} else if( SQL_ERROR == Sql_Query(sql_handle,
|
||||
"UPDATE `%s` SET `char_id` = '%d', `class` = '%d', `mode` = '%d', `hp` = '%d', `sp` = '%d',"
|
||||
"`max_hp` = '%d', `max_sp` = '%d', `atk1` = '%d', `atk2` = '%d', `matk` = '%d', `aspd` = '%d', `def` = '%d',"
|
||||
"`mdef` = '%d', `flee` = '%d', `hit` = '%d', `life_time` = '%u' WHERE `ele_id` = '%d'",elemental_db,
|
||||
"`mdef` = '%d', `flee` = '%d', `hit` = '%d', `life_time` = '%u' WHERE `ele_id` = '%d'", schema_config.elemental_db,
|
||||
ele->char_id, ele->class_, ele->mode, ele->hp, ele->sp, ele->max_hp, ele->max_sp, ele->atk, ele->atk2,
|
||||
ele->matk, ele->amotion, ele->def, ele->mdef, ele->flee, ele->hit, ele->life_time, ele->elemental_id) )
|
||||
{ // Update DB entry
|
||||
@ -44,23 +44,23 @@ bool mapif_elemental_save(struct s_elemental* ele) {
|
||||
|
||||
bool mapif_elemental_load(int ele_id, int char_id, struct s_elemental *ele) {
|
||||
char* data;
|
||||
|
||||
|
||||
memset(ele, 0, sizeof(struct s_elemental));
|
||||
ele->elemental_id = ele_id;
|
||||
ele->char_id = char_id;
|
||||
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `class`, `mode`, `hp`, `sp`, `max_hp`, `max_sp`, `atk1`, `atk2`, `matk`, `aspd`,"
|
||||
"`def`, `mdef`, `flee`, `hit`, `life_time` FROM `%s` WHERE `ele_id` = '%d' AND `char_id` = '%d'",
|
||||
elemental_db, ele_id, char_id) ) {
|
||||
schema_config.elemental_db, ele_id, char_id) ) {
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if( SQL_SUCCESS != Sql_NextRow(sql_handle) ) {
|
||||
Sql_FreeResult(sql_handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Sql_GetData(sql_handle, 0, &data, NULL); ele->class_ = atoi(data);
|
||||
Sql_GetData(sql_handle, 1, &data, NULL); ele->mode = atoi(data);
|
||||
Sql_GetData(sql_handle, 2, &data, NULL); ele->hp = atoi(data);
|
||||
@ -77,24 +77,24 @@ bool mapif_elemental_load(int ele_id, int char_id, struct s_elemental *ele) {
|
||||
Sql_GetData(sql_handle, 13, &data, NULL); ele->hit = atoi(data);
|
||||
Sql_GetData(sql_handle, 14, &data, NULL); ele->life_time = atoi(data);
|
||||
Sql_FreeResult(sql_handle);
|
||||
if( save_log )
|
||||
if( charserv_config.save_log )
|
||||
ShowInfo("Elemental loaded (%d - %d).\n", ele->elemental_id, ele->char_id);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool mapif_elemental_delete(int ele_id) {
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `ele_id` = '%d'", elemental_db, ele_id) ) {
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `ele_id` = '%d'", schema_config.elemental_db, ele_id) ) {
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void mapif_elemental_send(int fd, struct s_elemental *ele, unsigned char flag) {
|
||||
int size = sizeof(struct s_elemental) + 5;
|
||||
|
||||
|
||||
WFIFOHEAD(fd,size);
|
||||
WFIFOW(fd,0) = 0x387c;
|
||||
WFIFOW(fd,2) = size;
|
||||
@ -150,7 +150,7 @@ void inter_elemental_sql_final(void) {
|
||||
*------------------------------------------*/
|
||||
int inter_elemental_parse_frommap(int fd) {
|
||||
unsigned short cmd = RFIFOW(fd,0);
|
||||
|
||||
|
||||
switch( cmd ) {
|
||||
case 0x307c: mapif_parse_elemental_create(fd, (struct s_elemental*)RFIFOP(fd,4)); break;
|
||||
case 0x307d: mapif_parse_elemental_load(fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6)); break;
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "../common/strlib.h"
|
||||
#include "../common/timer.h"
|
||||
#include "char.h"
|
||||
#include "char_mapif.h"
|
||||
#include "inter.h"
|
||||
#include "int_guild.h"
|
||||
|
||||
@ -72,7 +73,7 @@ static int guild_save_timer(int tid, unsigned int tick, int id, intptr_t data)
|
||||
|
||||
if( g->save_flag == GS_REMOVE )
|
||||
{// Nothing to save, guild is ready for removal.
|
||||
if (save_log)
|
||||
if (charserv_config.save_log)
|
||||
ShowInfo("Guild Unloaded (%d - %s)\n", g->guild_id, g->name);
|
||||
db_remove(guild_db_, key);
|
||||
}
|
||||
@ -84,15 +85,15 @@ static int guild_save_timer(int tid, unsigned int tick, int id, intptr_t data)
|
||||
|
||||
state = guild_db_->size(guild_db_);
|
||||
if( state < 1 ) state = 1; //Calculate the time slot for the next save.
|
||||
add_timer(tick + autosave_interval/state, guild_save_timer, 0, 0);
|
||||
add_timer(tick + (charserv_config.autosave_interval)/state, guild_save_timer, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int inter_guild_removemember_tosql(int account_id, int char_id)
|
||||
{
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE from `%s` where `account_id` = '%d' and `char_id` = '%d'", guild_member_db, account_id, char_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE from `%s` where `account_id` = '%d' and `char_id` = '%d'", schema_config.guild_member_db, account_id, char_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `guild_id` = '0' WHERE `char_id` = '%d'", char_db, char_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `guild_id` = '0' WHERE `char_id` = '%d'", schema_config.char_db, char_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return 0;
|
||||
}
|
||||
@ -140,7 +141,7 @@ int inter_guild_tosql(struct guild *g,int flag)
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` "
|
||||
"(`name`,`master`,`guild_lv`,`max_member`,`average_lv`,`char_id`) "
|
||||
"VALUES ('%s', '%s', '%d', '%d', '%d', '%d')",
|
||||
guild_db, esc_name, esc_master, g->guild_lv, g->max_member, g->average_lv, g->member[0].char_id) )
|
||||
schema_config.guild_db, esc_name, esc_master, g->guild_lv, g->max_member, g->average_lv, g->member[0].char_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
if (g->guild_id == -1)
|
||||
@ -160,7 +161,7 @@ int inter_guild_tosql(struct guild *g,int flag)
|
||||
bool add_comma = false;
|
||||
|
||||
StringBuf_Init(&buf);
|
||||
StringBuf_Printf(&buf, "UPDATE `%s` SET ", guild_db);
|
||||
StringBuf_Printf(&buf, "UPDATE `%s` SET ", schema_config.guild_db);
|
||||
|
||||
if (flag & GS_EMBLEM)
|
||||
{
|
||||
@ -238,14 +239,14 @@ int inter_guild_tosql(struct guild *g,int flag)
|
||||
Sql_EscapeStringLen(sql_handle, esc_name, m->name, strnlen(m->name, NAME_LENGTH));
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`guild_id`,`account_id`,`char_id`,`hair`,`hair_color`,`gender`,`class`,`lv`,`exp`,`exp_payper`,`online`,`position`,`name`) "
|
||||
"VALUES ('%d','%d','%d','%d','%d','%d','%d','%d','%"PRIu64"','%d','%d','%d','%s')",
|
||||
guild_member_db, g->guild_id, m->account_id, m->char_id,
|
||||
schema_config.guild_member_db, g->guild_id, m->account_id, m->char_id,
|
||||
m->hair, m->hair_color, m->gender,
|
||||
m->class_, m->lv, m->exp, m->exp_payper, m->online, m->position, esc_name) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
if (m->modified&GS_MEMBER_NEW || new_guild == 1)
|
||||
{
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `guild_id` = '%d' WHERE `char_id` = '%d'",
|
||||
char_db, g->guild_id, m->char_id) )
|
||||
schema_config.char_db, g->guild_id, m->char_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
}
|
||||
m->modified = GS_MEMBER_UNMODIFIED;
|
||||
@ -262,7 +263,7 @@ int inter_guild_tosql(struct guild *g,int flag)
|
||||
continue;
|
||||
Sql_EscapeStringLen(sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH));
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`guild_id`,`position`,`name`,`mode`,`exp_mode`) VALUES ('%d','%d','%s','%d','%d')",
|
||||
guild_position_db, g->guild_id, i, esc_name, p->mode, p->exp_mode) )
|
||||
schema_config.guild_position_db, g->guild_id, i, esc_name, p->mode, p->exp_mode) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
p->modified = GS_POSITION_UNMODIFIED;
|
||||
}
|
||||
@ -275,7 +276,7 @@ int inter_guild_tosql(struct guild *g,int flag)
|
||||
// their info changed, not to mention this would also mess up oppositions!
|
||||
// [Skotlex]
|
||||
//if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id`='%d' OR `alliance_id`='%d'", guild_alliance_db, g->guild_id, g->guild_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id`='%d'", guild_alliance_db, g->guild_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id`='%d'", schema_config.guild_alliance_db, g->guild_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
}
|
||||
@ -290,7 +291,7 @@ int inter_guild_tosql(struct guild *g,int flag)
|
||||
Sql_EscapeStringLen(sql_handle, esc_name, a->name, strnlen(a->name, NAME_LENGTH));
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`guild_id`,`opposition`,`alliance_id`,`name`) "
|
||||
"VALUES ('%d','%d','%d','%s')",
|
||||
guild_alliance_db, g->guild_id, a->opposition, a->guild_id, esc_name) )
|
||||
schema_config.guild_alliance_db, g->guild_id, a->opposition, a->guild_id, esc_name) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
}
|
||||
}
|
||||
@ -308,7 +309,7 @@ int inter_guild_tosql(struct guild *g,int flag)
|
||||
Sql_EscapeStringLen(sql_handle, esc_name, e->name, strnlen(e->name, NAME_LENGTH));
|
||||
Sql_EscapeStringLen(sql_handle, esc_mes, e->mes, strnlen(e->mes, sizeof(e->mes)));
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`guild_id`,`account_id`,`name`,`mes`) "
|
||||
"VALUES ('%d','%d','%s','%s')", guild_expulsion_db, g->guild_id, e->account_id, esc_name, esc_mes) )
|
||||
"VALUES ('%d','%d','%s','%s')", schema_config.guild_expulsion_db, g->guild_id, e->account_id, esc_name, esc_mes) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
}
|
||||
}
|
||||
@ -320,13 +321,13 @@ int inter_guild_tosql(struct guild *g,int flag)
|
||||
for(i=0;i<MAX_GUILDSKILL;i++){
|
||||
if (g->skill[i].id>0 && g->skill[i].lv>0){
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`guild_id`,`id`,`lv`) VALUES ('%d','%d','%d')",
|
||||
guild_skill_db, g->guild_id, g->skill[i].id, g->skill[i].lv) )
|
||||
schema_config.guild_skill_db, g->guild_id, g->skill[i].id, g->skill[i].lv) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (save_log)
|
||||
if (charserv_config.save_log)
|
||||
ShowInfo("Saved guild (%d - %s):%s\n",g->guild_id,g->name,t_info);
|
||||
return 1;
|
||||
}
|
||||
@ -352,7 +353,7 @@ struct guild * inter_guild_fromsql(int guild_id)
|
||||
#endif
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT g.`name`,c.`name`,g.`guild_lv`,g.`connect_member`,g.`max_member`,g.`average_lv`,g.`exp`,g.`next_exp`,g.`skill_point`,g.`mes1`,g.`mes2`,g.`emblem_len`,g.`emblem_id`,g.`emblem_data` "
|
||||
"FROM `%s` g LEFT JOIN `%s` c ON c.`char_id` = g.`char_id` WHERE g.`guild_id`='%d'", guild_db, char_db, guild_id) )
|
||||
"FROM `%s` g LEFT JOIN `%s` c ON c.`char_id` = g.`char_id` WHERE g.`guild_id`='%d'", schema_config.guild_db, schema_config.char_db, guild_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return NULL;
|
||||
@ -407,7 +408,7 @@ struct guild * inter_guild_fromsql(int guild_id)
|
||||
|
||||
// load guild member info
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`,`char_id`,`hair`,`hair_color`,`gender`,`class`,`lv`,`exp`,`exp_payper`,`online`,`position`,`name` "
|
||||
"FROM `%s` WHERE `guild_id`='%d' ORDER BY `position`", guild_member_db, guild_id) )
|
||||
"FROM `%s` WHERE `guild_id`='%d' ORDER BY `position`", schema_config.guild_member_db, guild_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
aFree(g);
|
||||
@ -435,7 +436,7 @@ struct guild * inter_guild_fromsql(int guild_id)
|
||||
}
|
||||
|
||||
//printf("- Read guild_position %d from sql \n",guild_id);
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `position`,`name`,`mode`,`exp_mode` FROM `%s` WHERE `guild_id`='%d'", guild_position_db, guild_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `position`,`name`,`mode`,`exp_mode` FROM `%s` WHERE `guild_id`='%d'", schema_config.guild_position_db, guild_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
aFree(g);
|
||||
@ -457,7 +458,7 @@ struct guild * inter_guild_fromsql(int guild_id)
|
||||
}
|
||||
|
||||
//printf("- Read guild_alliance %d from sql \n",guild_id);
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `opposition`,`alliance_id`,`name` FROM `%s` WHERE `guild_id`='%d'", guild_alliance_db, guild_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `opposition`,`alliance_id`,`name` FROM `%s` WHERE `guild_id`='%d'", schema_config.guild_alliance_db, guild_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
aFree(g);
|
||||
@ -473,7 +474,7 @@ struct guild * inter_guild_fromsql(int guild_id)
|
||||
}
|
||||
|
||||
//printf("- Read guild_expulsion %d from sql \n",guild_id);
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`,`name`,`mes` FROM `%s` WHERE `guild_id`='%d'", guild_expulsion_db, guild_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`,`name`,`mes` FROM `%s` WHERE `guild_id`='%d'", schema_config.guild_expulsion_db, guild_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
aFree(g);
|
||||
@ -489,7 +490,7 @@ struct guild * inter_guild_fromsql(int guild_id)
|
||||
}
|
||||
|
||||
//printf("- Read guild_skill %d from sql \n",guild_id);
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `id`,`lv` FROM `%s` WHERE `guild_id`='%d' ORDER BY `id`", guild_skill_db, guild_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `id`,`lv` FROM `%s` WHERE `guild_id`='%d' ORDER BY `id`", schema_config.guild_skill_db, guild_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
aFree(g);
|
||||
@ -514,7 +515,7 @@ struct guild * inter_guild_fromsql(int guild_id)
|
||||
idb_put(guild_db_, guild_id, g); //Add to cache
|
||||
g->save_flag |= GS_REMOVE; //But set it to be removed, in case it is not needed for long.
|
||||
|
||||
if (save_log)
|
||||
if (charserv_config.save_log)
|
||||
ShowInfo("Guild loaded (%d - %s)\n", guild_id, g->name);
|
||||
|
||||
return g;
|
||||
@ -528,15 +529,15 @@ int inter_guildcastle_tosql(struct guild_castle *gc)
|
||||
|
||||
StringBuf_Init(&buf);
|
||||
StringBuf_Printf(&buf, "REPLACE INTO `%s` SET `castle_id`='%d', `guild_id`='%d', `economy`='%d', `defense`='%d', "
|
||||
"`triggerE`='%d', `triggerD`='%d', `nextTime`='%d', `payTime`='%d', `createTime`='%d', `visibleC`='%d'",
|
||||
guild_castle_db, gc->castle_id, gc->guild_id, gc->economy, gc->defense,
|
||||
gc->triggerE, gc->triggerD, gc->nextTime, gc->payTime, gc->createTime, gc->visibleC);
|
||||
"`triggerE`='%d', `triggerD`='%d', `nextTime`='%d', `payTime`='%d', `createTime`='%d', `visibleC`='%d'",
|
||||
schema_config.guild_castle_db, gc->castle_id, gc->guild_id, gc->economy, gc->defense,
|
||||
gc->triggerE, gc->triggerD, gc->nextTime, gc->payTime, gc->createTime, gc->visibleC);
|
||||
for (i = 0; i < MAX_GUARDIANS; ++i)
|
||||
StringBuf_Printf(&buf, ", `visibleG%d`='%d'", i, gc->guardian[i].visible);
|
||||
|
||||
if (SQL_ERROR == Sql_Query(sql_handle, StringBuf_Value(&buf)))
|
||||
Sql_ShowDebug(sql_handle);
|
||||
else if(save_log)
|
||||
else if(charserv_config.save_log)
|
||||
ShowInfo("Saved guild castle (%d)\n", gc->castle_id);
|
||||
|
||||
StringBuf_Destroy(&buf);
|
||||
@ -559,7 +560,7 @@ static struct guild_castle* inter_guildcastle_fromsql(int castle_id)
|
||||
"`triggerD`, `nextTime`, `payTime`, `createTime`, `visibleC`");
|
||||
for (i = 0; i < MAX_GUARDIANS; ++i)
|
||||
StringBuf_Printf(&buf, ", `visibleG%d`", i);
|
||||
StringBuf_Printf(&buf, " FROM `%s` WHERE `castle_id`='%d'", guild_castle_db, castle_id);
|
||||
StringBuf_Printf(&buf, " FROM `%s` WHERE `castle_id`='%d'", schema_config.guild_castle_db, castle_id);
|
||||
if (SQL_ERROR == Sql_Query(sql_handle, StringBuf_Value(&buf))) {
|
||||
Sql_ShowDebug(sql_handle);
|
||||
StringBuf_Destroy(&buf);
|
||||
@ -588,7 +589,7 @@ static struct guild_castle* inter_guildcastle_fromsql(int castle_id)
|
||||
|
||||
idb_put(castle_db, castle_id, gc);
|
||||
|
||||
if (save_log)
|
||||
if (charserv_config.save_log)
|
||||
ShowInfo("Loaded guild castle (%d - guild %d)\n", castle_id, gc->guild_id);
|
||||
|
||||
return gc;
|
||||
@ -617,7 +618,7 @@ int inter_guild_CharOnline(int char_id, int guild_id)
|
||||
|
||||
if (guild_id == -1) {
|
||||
//Get guild_id from the database
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT guild_id FROM `%s` WHERE char_id='%d'", char_db, char_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT guild_id FROM `%s` WHERE char_id='%d'", schema_config.char_db, char_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return 0;
|
||||
@ -668,7 +669,7 @@ int inter_guild_CharOffline(int char_id, int guild_id)
|
||||
if (guild_id == -1)
|
||||
{
|
||||
//Get guild_id from the database
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT guild_id FROM `%s` WHERE char_id='%d'", char_db, char_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT guild_id FROM `%s` WHERE char_id='%d'", schema_config.char_db, char_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return 0;
|
||||
@ -762,7 +763,7 @@ int search_guildname(char *str)
|
||||
|
||||
Sql_EscapeStringLen(sql_handle, esc_name, str, safestrnlen(str, NAME_LENGTH));
|
||||
//Lookup guilds with the same name
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT guild_id FROM `%s` WHERE name='%s'", guild_db, esc_name) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT guild_id FROM `%s` WHERE name='%s'", schema_config.guild_db, esc_name) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return -1;
|
||||
@ -908,9 +909,9 @@ int mapif_guild_noinfo(int fd,int guild_id)
|
||||
WBUFL(buf,4)=guild_id;
|
||||
ShowWarning("int_guild: info not found %d\n",guild_id);
|
||||
if(fd<0)
|
||||
mapif_sendall(buf,8);
|
||||
chmapif_sendall(buf,8);
|
||||
else
|
||||
mapif_send(fd,buf,8);
|
||||
chmapif_send(fd,buf,8);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -922,9 +923,9 @@ int mapif_guild_info(int fd,struct guild *g)
|
||||
WBUFW(buf,2)=4+sizeof(struct guild);
|
||||
memcpy(buf+4,g,sizeof(struct guild));
|
||||
if(fd<0)
|
||||
mapif_sendall(buf,WBUFW(buf,2));
|
||||
chmapif_sendall(buf,WBUFW(buf,2));
|
||||
else
|
||||
mapif_send(fd,buf,WBUFW(buf,2));
|
||||
chmapif_send(fd,buf,WBUFW(buf,2));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -952,7 +953,7 @@ int mapif_guild_withdraw(int guild_id,int account_id,int char_id,int flag, const
|
||||
WBUFB(buf,14)=flag;
|
||||
memcpy(WBUFP(buf,15),mes,40);
|
||||
memcpy(WBUFP(buf,55),name,NAME_LENGTH);
|
||||
mapif_sendall(buf,55+NAME_LENGTH);
|
||||
chmapif_sendall(buf,55+NAME_LENGTH);
|
||||
ShowInfo("int_guild: guild withdraw (%d - %d: %s - %s)\n",guild_id,account_id,name,mes);
|
||||
return 0;
|
||||
}
|
||||
@ -968,7 +969,7 @@ int mapif_guild_memberinfoshort(struct guild *g,int idx)
|
||||
WBUFB(buf,14)=(unsigned char)g->member[idx].online;
|
||||
WBUFW(buf,15)=g->member[idx].lv;
|
||||
WBUFW(buf,17)=g->member[idx].class_;
|
||||
mapif_sendall(buf,19);
|
||||
chmapif_sendall(buf,19);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -979,7 +980,7 @@ int mapif_guild_broken(int guild_id,int flag)
|
||||
WBUFW(buf,0)=0x3836;
|
||||
WBUFL(buf,2)=guild_id;
|
||||
WBUFB(buf,6)=flag;
|
||||
mapif_sendall(buf,7);
|
||||
chmapif_sendall(buf,7);
|
||||
ShowInfo("int_guild: Guild broken (%d)\n",guild_id);
|
||||
return 0;
|
||||
}
|
||||
@ -995,7 +996,7 @@ int mapif_guild_message(int guild_id,int account_id,char *mes,int len, int sfd)
|
||||
WBUFL(buf,4)=guild_id;
|
||||
WBUFL(buf,8)=account_id;
|
||||
memcpy(WBUFP(buf,12),mes,len);
|
||||
mapif_sendallwos(sfd, buf,len+12);
|
||||
chmapif_sendallwos(sfd, buf,len+12);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1010,7 +1011,7 @@ int mapif_guild_basicinfochanged(int guild_id,int type,const void *data,int len)
|
||||
WBUFL(buf, 4)=guild_id;
|
||||
WBUFW(buf, 8)=type;
|
||||
memcpy(WBUFP(buf,10),data,len);
|
||||
mapif_sendall(buf,len+10);
|
||||
chmapif_sendall(buf,len+10);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1027,7 +1028,7 @@ int mapif_guild_memberinfochanged(int guild_id,int account_id,int char_id, int t
|
||||
WBUFL(buf,12)=char_id;
|
||||
WBUFW(buf,16)=type;
|
||||
memcpy(WBUFP(buf,18),data,len);
|
||||
mapif_sendall(buf,len+18);
|
||||
chmapif_sendall(buf,len+18);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1039,7 +1040,7 @@ int mapif_guild_skillupack(int guild_id,uint16 skill_id,int account_id)
|
||||
WBUFL(buf, 2)=guild_id;
|
||||
WBUFL(buf, 6)=skill_id;
|
||||
WBUFL(buf,10)=account_id;
|
||||
mapif_sendall(buf,14);
|
||||
chmapif_sendall(buf,14);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1055,7 +1056,7 @@ int mapif_guild_alliance(int guild_id1,int guild_id2,int account_id1,int account
|
||||
WBUFB(buf,18)=flag;
|
||||
memcpy(WBUFP(buf,19),name1,NAME_LENGTH);
|
||||
memcpy(WBUFP(buf,19+NAME_LENGTH),name2,NAME_LENGTH);
|
||||
mapif_sendall(buf,19+2*NAME_LENGTH);
|
||||
chmapif_sendall(buf,19+2*NAME_LENGTH);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1068,7 +1069,7 @@ int mapif_guild_position(struct guild *g,int idx)
|
||||
WBUFL(buf,4)=g->guild_id;
|
||||
WBUFL(buf,8)=idx;
|
||||
memcpy(WBUFP(buf,12),&g->position[idx],sizeof(struct guild_position));
|
||||
mapif_sendall(buf,WBUFW(buf,2));
|
||||
chmapif_sendall(buf,WBUFW(buf,2));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1080,7 +1081,7 @@ int mapif_guild_notice(struct guild *g)
|
||||
WBUFL(buf,2)=g->guild_id;
|
||||
memcpy(WBUFP(buf,6),g->mes1,MAX_GUILDMES1);
|
||||
memcpy(WBUFP(buf,66),g->mes2,MAX_GUILDMES2);
|
||||
mapif_sendall(buf,186);
|
||||
chmapif_sendall(buf,186);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1093,7 +1094,7 @@ int mapif_guild_emblem(struct guild *g)
|
||||
WBUFL(buf,4)=g->guild_id;
|
||||
WBUFL(buf,8)=g->emblem_id;
|
||||
memcpy(WBUFP(buf,12),g->emblem_data,g->emblem_len);
|
||||
mapif_sendall(buf,WBUFW(buf,2));
|
||||
chmapif_sendall(buf,WBUFW(buf,2));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1104,7 +1105,7 @@ int mapif_guild_master_changed(struct guild *g, int aid, int cid)
|
||||
WBUFL(buf,2)=g->guild_id;
|
||||
WBUFL(buf,6)=aid;
|
||||
WBUFL(buf,10)=cid;
|
||||
mapif_sendall(buf,14);
|
||||
chmapif_sendall(buf,14);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1144,15 +1145,15 @@ int mapif_parse_CreateGuild(int fd,int account_id,char *name,struct guild_member
|
||||
return 0;
|
||||
}
|
||||
// Check Authorised letters/symbols in the name of the character
|
||||
if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorised
|
||||
if (charserv_config.char_config.char_name_option == 1) { // only letters/symbols in char_name_letters are authorised
|
||||
for (i = 0; i < NAME_LENGTH && name[i]; i++)
|
||||
if (strchr(char_name_letters, name[i]) == NULL) {
|
||||
if (strchr(charserv_config.char_config.char_name_letters, name[i]) == NULL) {
|
||||
mapif_guild_created(fd,account_id,NULL);
|
||||
return 0;
|
||||
}
|
||||
} else if (char_name_option == 2) { // letters/symbols in char_name_letters are forbidden
|
||||
} else if (charserv_config.char_config.char_name_option == 2) { // letters/symbols in char_name_letters are forbidden
|
||||
for (i = 0; i < NAME_LENGTH && name[i]; i++)
|
||||
if (strchr(char_name_letters, name[i]) != NULL) {
|
||||
if (strchr(charserv_config.char_config.char_name_letters, name[i]) != NULL) {
|
||||
mapif_guild_created(fd,account_id,NULL);
|
||||
return 0;
|
||||
}
|
||||
@ -1202,7 +1203,7 @@ int mapif_parse_CreateGuild(int fd,int account_id,char *name,struct guild_member
|
||||
mapif_guild_created(fd,account_id,g);
|
||||
mapif_guild_info(fd,g);
|
||||
|
||||
if(log_inter)
|
||||
if(charserv_config.log_inter)
|
||||
inter_log("guild %s (id=%d) created by master %s (id=%d)\n",
|
||||
name, g->guild_id, master->name, master->account_id );
|
||||
|
||||
@ -1268,7 +1269,7 @@ int mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, in
|
||||
if( g == NULL )
|
||||
{
|
||||
// Unknown guild, just update the player
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `guild_id`='0' WHERE `account_id`='%d' AND `char_id`='%d'", char_db, account_id, char_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `guild_id`='0' WHERE `account_id`='%d' AND `char_id`='%d'", schema_config.char_db, account_id, char_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
// mapif_guild_withdraw(guild_id,account_id,char_id,flag,g->member[i].name,mes);
|
||||
return 0;
|
||||
@ -1381,37 +1382,37 @@ int mapif_parse_BreakGuild(int fd,int guild_id)
|
||||
|
||||
// Delete guild from sql
|
||||
//printf("- Delete guild %d from guild\n",guild_id);
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_db, guild_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", schema_config.guild_db, guild_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_member_db, guild_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", schema_config.guild_member_db, guild_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_castle_db, guild_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", schema_config.guild_castle_db, guild_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_storage_db, guild_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", schema_config.guild_storage_db, guild_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d' OR `alliance_id` = '%d'", guild_alliance_db, guild_id, guild_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d' OR `alliance_id` = '%d'", schema_config.guild_alliance_db, guild_id, guild_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_position_db, guild_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", schema_config.guild_position_db, guild_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_skill_db, guild_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", schema_config.guild_skill_db, guild_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", guild_expulsion_db, guild_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id` = '%d'", schema_config.guild_expulsion_db, guild_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
//printf("- Update guild %d of char\n",guild_id);
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `guild_id`='0' WHERE `guild_id`='%d'", char_db, guild_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `guild_id`='0' WHERE `guild_id`='%d'", schema_config.char_db, guild_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
mapif_guild_broken(guild_id,0);
|
||||
|
||||
if(log_inter)
|
||||
if(charserv_config.log_inter)
|
||||
inter_log("guild %s (id=%d) broken\n",g->name,guild_id);
|
||||
|
||||
//Remove the guild from memory. [Skotlex]
|
||||
@ -1499,8 +1500,8 @@ int mapif_parse_GuildMemberInfoChange(int fd,int guild_id,int account_id,int cha
|
||||
exp = g->member[i].exp - old_exp;
|
||||
|
||||
// Compute gained exp
|
||||
if (guild_exp_rate != 100)
|
||||
exp = exp*guild_exp_rate/100;
|
||||
if (charserv_config.guild_exp_rate != 100)
|
||||
exp = exp*(charserv_config.guild_exp_rate)/100;
|
||||
|
||||
// Update guild exp
|
||||
if (exp > UINT64_MAX - g->exp)
|
||||
@ -1761,7 +1762,7 @@ int mapif_parse_GuildCastleDataSave(int fd, int castle_id, int index, int value)
|
||||
|
||||
switch (index) {
|
||||
case 1:
|
||||
if (log_inter && gc->guild_id != value) {
|
||||
if (charserv_config.log_inter && gc->guild_id != value) {
|
||||
int gid = (value) ? value : gc->guild_id;
|
||||
struct guild *g = idb_get(guild_db_, gid);
|
||||
inter_log("guild %s (id=%d) %s castle id=%d\n",
|
||||
|
@ -95,7 +95,7 @@ bool mapif_homunculus_save(struct s_homunculus* hd)
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` "
|
||||
"(`char_id`, `class`,`prev_class`,`name`,`level`,`exp`,`intimacy`,`hunger`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `hp`,`max_hp`,`sp`,`max_sp`,`skill_point`, `rename_flag`, `vaporize`) "
|
||||
"VALUES ('%d', '%d', '%d', '%s', '%d', '%u', '%u', '%d', '%d', %d, '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')",
|
||||
homunculus_db, hd->char_id, hd->class_, hd->prev_class, esc_name, hd->level, hd->exp, hd->intimacy, hd->hunger, hd->str, hd->agi, hd->vit, hd->int_, hd->dex, hd->luk,
|
||||
schema_config.homunculus_db, hd->char_id, hd->class_, hd->prev_class, esc_name, hd->level, hd->exp, hd->intimacy, hd->hunger, hd->str, hd->agi, hd->vit, hd->int_, hd->dex, hd->luk,
|
||||
hd->hp, hd->max_hp, hd->sp, hd->max_sp, hd->skillpts, hd->rename_flag, hd->vaporize) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
@ -109,7 +109,7 @@ bool mapif_homunculus_save(struct s_homunculus* hd)
|
||||
else
|
||||
{
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `char_id`='%d', `class`='%d',`prev_class`='%d',`name`='%s',`level`='%d',`exp`='%u',`intimacy`='%u',`hunger`='%d', `str`='%d', `agi`='%d', `vit`='%d', `int`='%d', `dex`='%d', `luk`='%d', `hp`='%d',`max_hp`='%d',`sp`='%d',`max_sp`='%d',`skill_point`='%d', `rename_flag`='%d', `vaporize`='%d' WHERE `homun_id`='%d'",
|
||||
homunculus_db, hd->char_id, hd->class_, hd->prev_class, esc_name, hd->level, hd->exp, hd->intimacy, hd->hunger, hd->str, hd->agi, hd->vit, hd->int_, hd->dex, hd->luk,
|
||||
schema_config.homunculus_db, hd->char_id, hd->class_, hd->prev_class, esc_name, hd->level, hd->exp, hd->intimacy, hd->hunger, hd->str, hd->agi, hd->vit, hd->int_, hd->dex, hd->luk,
|
||||
hd->hp, hd->max_hp, hd->sp, hd->max_sp, hd->skillpts, hd->rename_flag, hd->vaporize, hd->hom_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
@ -121,7 +121,7 @@ bool mapif_homunculus_save(struct s_homunculus* hd)
|
||||
int i;
|
||||
|
||||
stmt = SqlStmt_Malloc(sql_handle);
|
||||
if( SQL_ERROR == SqlStmt_Prepare(stmt, "REPLACE INTO `%s` (`homun_id`, `id`, `lv`) VALUES (%d, ?, ?)", skill_homunculus_db, hd->hom_id) )
|
||||
if( SQL_ERROR == SqlStmt_Prepare(stmt, "REPLACE INTO `%s` (`homun_id`, `id`, `lv`) VALUES (%d, ?, ?)", schema_config.skill_homunculus_db, hd->hom_id) )
|
||||
SqlStmt_ShowDebug(stmt);
|
||||
for( i = 0; i < MAX_HOMUNSKILL; ++i )
|
||||
{
|
||||
@ -155,7 +155,8 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd)
|
||||
|
||||
memset(hd, 0, sizeof(*hd));
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `homun_id`,`char_id`,`class`,`prev_class`,`name`,`level`,`exp`,`intimacy`,`hunger`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `hp`,`max_hp`,`sp`,`max_sp`,`skill_point`,`rename_flag`, `vaporize` FROM `%s` WHERE `homun_id`='%u'", homunculus_db, homun_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `homun_id`,`char_id`,`class`,`prev_class`,`name`,`level`,`exp`,`intimacy`,`hunger`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `hp`,`max_hp`,`sp`,`max_sp`,`skill_point`,`rename_flag`, `vaporize` FROM `%s` WHERE `homun_id`='%u'",
|
||||
schema_config.homunculus_db, homun_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return false;
|
||||
@ -201,7 +202,7 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd)
|
||||
hd->hunger = cap_value(hd->hunger, 0, 100);
|
||||
|
||||
// Load Homunculus Skill
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `id`,`lv` FROM `%s` WHERE `homun_id`=%d", skill_homunculus_db, homun_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `id`,`lv` FROM `%s` WHERE `homun_id`=%d", schema_config.skill_homunculus_db, homun_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return false;
|
||||
@ -223,7 +224,7 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd)
|
||||
}
|
||||
Sql_FreeResult(sql_handle);
|
||||
|
||||
if( save_log )
|
||||
if( charserv_config.save_log )
|
||||
ShowInfo("Homunculus loaded (%d - %s).\n", hd->hom_id, hd->name);
|
||||
|
||||
return true;
|
||||
@ -231,8 +232,8 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd)
|
||||
|
||||
bool mapif_homunculus_delete(int homun_id)
|
||||
{
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `homun_id` = '%u'", homunculus_db, homun_id)
|
||||
|| SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `homun_id` = '%u'", skill_homunculus_db, homun_id)
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `homun_id` = '%u'", schema_config.homunculus_db, homun_id)
|
||||
|| SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `homun_id` = '%u'", schema_config.skill_homunculus_db, homun_id)
|
||||
) {
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return false;
|
||||
@ -245,16 +246,16 @@ bool mapif_homunculus_rename(char *name)
|
||||
int i;
|
||||
|
||||
// Check Authorised letters/symbols in the name of the homun
|
||||
if( char_name_option == 1 )
|
||||
if( charserv_config.char_config.char_name_option == 1 )
|
||||
{// only letters/symbols in char_name_letters are authorised
|
||||
for( i = 0; i < NAME_LENGTH && name[i]; i++ )
|
||||
if( strchr(char_name_letters, name[i]) == NULL )
|
||||
if( strchr(charserv_config.char_config.char_name_letters, name[i]) == NULL )
|
||||
return false;
|
||||
} else
|
||||
if( char_name_option == 2 )
|
||||
if( charserv_config.char_config.char_name_option == 2 )
|
||||
{// letters/symbols in char_name_letters are forbidden
|
||||
for( i = 0; i < NAME_LENGTH && name[i]; i++ )
|
||||
if( strchr(char_name_letters, name[i]) != NULL )
|
||||
if( strchr(charserv_config.char_config.char_name_letters, name[i]) != NULL )
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "../common/sql.h"
|
||||
#include "../common/timer.h"
|
||||
#include "char.h"
|
||||
#include "char_mapif.h"
|
||||
#include "inter.h"
|
||||
|
||||
#include <stdio.h>
|
||||
@ -35,7 +36,7 @@ static int mail_fromsql(int char_id, struct mail_data* md)
|
||||
|
||||
// I keep the `status` < 3 just in case someone forget to apply the sqlfix
|
||||
StringBuf_Printf(&buf, " FROM `%s` WHERE `dest_id`='%d' AND `status` < 3 ORDER BY `id` LIMIT %d",
|
||||
mail_db, char_id, MAIL_MAX_INBOX + 1);
|
||||
schema_config.mail_db, char_id, MAIL_MAX_INBOX + 1);
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, StringBuf_Value(&buf)) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
@ -84,7 +85,7 @@ static int mail_fromsql(int char_id, struct mail_data* md)
|
||||
msg = &md->msg[i];
|
||||
if( msg->status == MAIL_NEW )
|
||||
{
|
||||
if ( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `status` = '%d' WHERE `id` = '%d'", mail_db, MAIL_UNREAD, msg->id) )
|
||||
if ( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `status` = '%d' WHERE `id` = '%d'", schema_config.mail_db, MAIL_UNREAD, msg->id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
msg->status = MAIL_UNREAD;
|
||||
@ -108,7 +109,7 @@ int mail_savemessage(struct mail_message* msg)
|
||||
|
||||
// build message save query
|
||||
StringBuf_Init(&buf);
|
||||
StringBuf_Printf(&buf, "INSERT INTO `%s` (`send_name`, `send_id`, `dest_name`, `dest_id`, `title`, `message`, `time`, `status`, `zeny`, `amount`, `nameid`, `refine`, `attribute`, `identify`, `unique_id`", mail_db);
|
||||
StringBuf_Printf(&buf, "INSERT INTO `%s` (`send_name`, `send_id`, `dest_name`, `dest_id`, `title`, `message`, `time`, `status`, `zeny`, `amount`, `nameid`, `refine`, `attribute`, `identify`, `unique_id`", schema_config.mail_db);
|
||||
for (j = 0; j < MAX_SLOTS; j++)
|
||||
StringBuf_Printf(&buf, ", `card%d`", j);
|
||||
StringBuf_Printf(&buf, ") VALUES (?, '%d', ?, '%d', ?, ?, '%lu', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%"PRIu64"'",
|
||||
@ -116,7 +117,7 @@ int mail_savemessage(struct mail_message* msg)
|
||||
for (j = 0; j < MAX_SLOTS; j++)
|
||||
StringBuf_Printf(&buf, ", '%d'", msg->item.card[j]);
|
||||
StringBuf_AppendStr(&buf, ")");
|
||||
|
||||
|
||||
//Unique Non Stackable Item ID
|
||||
updateLastUid(msg->item.unique_id);
|
||||
dbUpdateUid(sql_handle);
|
||||
@ -153,7 +154,7 @@ static bool mail_loadmessage(int mail_id, struct mail_message* msg)
|
||||
"`zeny`,`amount`,`nameid`,`refine`,`attribute`,`identify`,`unique_id`");
|
||||
for( j = 0; j < MAX_SLOTS; j++ )
|
||||
StringBuf_Printf(&buf, ",`card%d`", j);
|
||||
StringBuf_Printf(&buf, " FROM `%s` WHERE `id` = '%d'", mail_db, mail_id);
|
||||
StringBuf_Printf(&buf, " FROM `%s` WHERE `id` = '%d'", schema_config.mail_db, mail_id);
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, StringBuf_Value(&buf))
|
||||
|| SQL_SUCCESS != Sql_NextRow(sql_handle) )
|
||||
@ -228,7 +229,7 @@ static void mapif_parse_Mail_requestinbox(int fd)
|
||||
static void mapif_parse_Mail_read(int fd)
|
||||
{
|
||||
int mail_id = RFIFOL(fd,2);
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `status` = '%d' WHERE `id` = '%d'", mail_db, MAIL_READ, mail_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `status` = '%d' WHERE `id` = '%d'", schema_config.mail_db, MAIL_READ, mail_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
}
|
||||
|
||||
@ -241,7 +242,7 @@ static bool mail_DeleteAttach(int mail_id)
|
||||
int i;
|
||||
|
||||
StringBuf_Init(&buf);
|
||||
StringBuf_Printf(&buf, "UPDATE `%s` SET `zeny` = '0', `nameid` = '0', `amount` = '0', `refine` = '0', `attribute` = '0', `identify` = '0'", mail_db);
|
||||
StringBuf_Printf(&buf, "UPDATE `%s` SET `zeny` = '0', `nameid` = '0', `amount` = '0', `refine` = '0', `attribute` = '0', `identify` = '0'", schema_config.mail_db);
|
||||
for (i = 0; i < MAX_SLOTS; i++)
|
||||
StringBuf_Printf(&buf, ", `card%d` = '0'", i);
|
||||
StringBuf_Printf(&buf, " WHERE `id` = '%d'", mail_id);
|
||||
@ -297,7 +298,7 @@ static void mapif_parse_Mail_getattach(int fd)
|
||||
static void mapif_Mail_delete(int fd, int char_id, int mail_id)
|
||||
{
|
||||
bool failed = false;
|
||||
if ( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `id` = '%d'", mail_db, mail_id) )
|
||||
if ( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `id` = '%d'", schema_config.mail_db, mail_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
failed = true;
|
||||
@ -322,7 +323,7 @@ static void mapif_parse_Mail_delete(int fd)
|
||||
void mapif_Mail_new(struct mail_message *msg)
|
||||
{
|
||||
unsigned char buf[74];
|
||||
|
||||
|
||||
if( !msg || !msg->id )
|
||||
return;
|
||||
|
||||
@ -331,7 +332,7 @@ void mapif_Mail_new(struct mail_message *msg)
|
||||
WBUFL(buf,6) = msg->id;
|
||||
memcpy(WBUFP(buf,10), msg->send_name, NAME_LENGTH);
|
||||
memcpy(WBUFP(buf,34), msg->title, MAIL_TITLE_LENGTH);
|
||||
mapif_sendall(buf, 74);
|
||||
chmapif_sendall(buf, 74);
|
||||
}
|
||||
|
||||
/*==========================================
|
||||
@ -346,7 +347,7 @@ static void mapif_Mail_return(int fd, int char_id, int mail_id)
|
||||
{
|
||||
if( msg.dest_id != char_id)
|
||||
return;
|
||||
else if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `id` = '%d'", mail_db, mail_id) )
|
||||
else if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `id` = '%d'", schema_config.mail_db, mail_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
else
|
||||
{
|
||||
@ -389,7 +390,7 @@ static void mapif_parse_Mail_return(int fd)
|
||||
static void mapif_Mail_send(int fd, struct mail_message* msg)
|
||||
{
|
||||
int len = sizeof(struct mail_message) + 4;
|
||||
|
||||
|
||||
WFIFOHEAD(fd,len);
|
||||
WFIFOW(fd,0) = 0x384d;
|
||||
WFIFOW(fd,2) = len;
|
||||
@ -411,7 +412,7 @@ static void mapif_parse_Mail_send(int fd)
|
||||
|
||||
// Try to find the Dest Char by Name
|
||||
Sql_EscapeStringLen(sql_handle, esc_name, msg.dest_name, strnlen(msg.dest_name, NAME_LENGTH));
|
||||
if ( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`, `char_id` FROM `%s` WHERE `name` = '%s'", char_db, esc_name) )
|
||||
if ( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`, `char_id` FROM `%s` WHERE `name` = '%s'", schema_config.char_db, esc_name) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
else
|
||||
if ( SQL_SUCCESS == Sql_NextRow(sql_handle) )
|
||||
|
@ -19,7 +19,7 @@ bool mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status)
|
||||
{
|
||||
char* data;
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `merc_id`, `arch_calls`, `arch_faith`, `spear_calls`, `spear_faith`, `sword_calls`, `sword_faith` FROM `%s` WHERE `char_id` = '%d'", mercenary_owner_db, char_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `merc_id`, `arch_calls`, `arch_faith`, `spear_calls`, `spear_faith`, `sword_calls`, `sword_faith` FROM `%s` WHERE `char_id` = '%d'", schema_config.mercenary_owner_db, char_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return false;
|
||||
@ -46,7 +46,7 @@ bool mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status)
|
||||
bool mercenary_owner_tosql(int char_id, struct mmo_charstatus *status)
|
||||
{
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`char_id`, `merc_id`, `arch_calls`, `arch_faith`, `spear_calls`, `spear_faith`, `sword_calls`, `sword_faith`) VALUES ('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')",
|
||||
mercenary_owner_db, char_id, status->mer_id, status->arch_calls, status->arch_faith, status->spear_calls, status->spear_faith, status->sword_calls, status->sword_faith) )
|
||||
schema_config.mercenary_owner_db, char_id, status->mer_id, status->arch_calls, status->arch_faith, status->spear_calls, status->spear_faith, status->sword_calls, status->sword_faith) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return false;
|
||||
@ -57,10 +57,10 @@ bool mercenary_owner_tosql(int char_id, struct mmo_charstatus *status)
|
||||
|
||||
bool mercenary_owner_delete(int char_id)
|
||||
{
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d'", mercenary_owner_db, char_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d'", schema_config.mercenary_owner_db, char_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d'", mercenary_db, char_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d'", schema_config.mercenary_db, char_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
return true;
|
||||
@ -74,7 +74,7 @@ bool mapif_mercenary_save(struct s_mercenary* merc)
|
||||
{ // Create new DB entry
|
||||
if( SQL_ERROR == Sql_Query(sql_handle,
|
||||
"INSERT INTO `%s` (`char_id`,`class`,`hp`,`sp`,`kill_counter`,`life_time`) VALUES ('%d','%d','%d','%d','%u','%u')",
|
||||
mercenary_db, merc->char_id, merc->class_, merc->hp, merc->sp, merc->kill_count, merc->life_time) )
|
||||
schema_config.mercenary_db, merc->char_id, merc->class_, merc->hp, merc->sp, merc->kill_count, merc->life_time) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
flag = false;
|
||||
@ -84,7 +84,7 @@ bool mapif_mercenary_save(struct s_mercenary* merc)
|
||||
}
|
||||
else if( SQL_ERROR == Sql_Query(sql_handle,
|
||||
"UPDATE `%s` SET `char_id` = '%d', `class` = '%d', `hp` = '%d', `sp` = '%d', `kill_counter` = '%u', `life_time` = '%u' WHERE `mer_id` = '%d'",
|
||||
mercenary_db, merc->char_id, merc->class_, merc->hp, merc->sp, merc->kill_count, merc->life_time, merc->mercenary_id) )
|
||||
schema_config.mercenary_db, merc->char_id, merc->class_, merc->hp, merc->sp, merc->kill_count, merc->life_time, merc->mercenary_id) )
|
||||
{ // Update DB entry
|
||||
Sql_ShowDebug(sql_handle);
|
||||
flag = false;
|
||||
@ -101,7 +101,7 @@ bool mapif_mercenary_load(int merc_id, int char_id, struct s_mercenary *merc)
|
||||
merc->mercenary_id = merc_id;
|
||||
merc->char_id = char_id;
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `class`, `hp`, `sp`, `kill_counter`, `life_time` FROM `%s` WHERE `mer_id` = '%d' AND `char_id` = '%d'", mercenary_db, merc_id, char_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `class`, `hp`, `sp`, `kill_counter`, `life_time` FROM `%s` WHERE `mer_id` = '%d' AND `char_id` = '%d'", schema_config.mercenary_db, merc_id, char_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return false;
|
||||
@ -119,15 +119,15 @@ bool mapif_mercenary_load(int merc_id, int char_id, struct s_mercenary *merc)
|
||||
Sql_GetData(sql_handle, 3, &data, NULL); merc->kill_count = atoi(data);
|
||||
Sql_GetData(sql_handle, 4, &data, NULL); merc->life_time = atoi(data);
|
||||
Sql_FreeResult(sql_handle);
|
||||
if( save_log )
|
||||
if( charserv_config.save_log )
|
||||
ShowInfo("Mercenary loaded (%d - %d).\n", merc->mercenary_id, merc->char_id);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool mapif_mercenary_delete(int merc_id)
|
||||
{
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `mer_id` = '%d'", mercenary_db, merc_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `mer_id` = '%d'", schema_config.mercenary_db, merc_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return false;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "../common/mapindex.h"
|
||||
#include "../common/sql.h"
|
||||
#include "char.h"
|
||||
#include "char_mapif.h"
|
||||
#include "inter.h"
|
||||
#include "int_party.h"
|
||||
|
||||
@ -129,9 +130,9 @@ int inter_party_tosql(struct party *p, int flag, int index)
|
||||
if( flag & PS_BREAK )
|
||||
{// Break the party
|
||||
// we'll skip name-checking and just reset everyone with the same party id [celest]
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", char_db, party_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", schema_config.char_db, party_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `party_id`='%d'", party_db, party_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `party_id`='%d'", schema_config.party_db, party_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
//Remove from memory
|
||||
idb_remove(party_db_, party_id);
|
||||
@ -143,7 +144,7 @@ int inter_party_tosql(struct party *p, int flag, int index)
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` "
|
||||
"(`name`, `exp`, `item`, `leader_id`, `leader_char`) "
|
||||
"VALUES ('%s', '%d', '%d', '%d', '%d')",
|
||||
party_db, esc_name, p->exp, p->item, p->member[index].account_id, p->member[index].char_id) )
|
||||
schema_config.party_db, esc_name, p->exp, p->item, p->member[index].account_id, p->member[index].char_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return 0;
|
||||
@ -154,32 +155,32 @@ int inter_party_tosql(struct party *p, int flag, int index)
|
||||
if( flag & PS_BASIC )
|
||||
{// Update party info.
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `name`='%s', `exp`='%d', `item`='%d' WHERE `party_id`='%d'",
|
||||
party_db, esc_name, p->exp, p->item, party_id) )
|
||||
schema_config.party_db, esc_name, p->exp, p->item, party_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
}
|
||||
|
||||
if( flag & PS_LEADER )
|
||||
{// Update leader
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `leader_id`='%d', `leader_char`='%d' WHERE `party_id`='%d'",
|
||||
party_db, p->member[index].account_id, p->member[index].char_id, party_id) )
|
||||
schema_config.party_db, p->member[index].account_id, p->member[index].char_id, party_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
}
|
||||
|
||||
|
||||
if( flag & PS_ADDMEMBER )
|
||||
{// Add one party member.
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `party_id`='%d' WHERE `account_id`='%d' AND `char_id`='%d'",
|
||||
char_db, party_id, p->member[index].account_id, p->member[index].char_id) )
|
||||
schema_config.char_db, party_id, p->member[index].account_id, p->member[index].char_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
}
|
||||
|
||||
if( flag & PS_DELMEMBER )
|
||||
{// Remove one party member.
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d' AND `account_id`='%d' AND `char_id`='%d'",
|
||||
char_db, party_id, p->member[index].account_id, p->member[index].char_id) )
|
||||
schema_config.char_db, party_id, p->member[index].account_id, p->member[index].char_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
}
|
||||
|
||||
if( save_log )
|
||||
if( charserv_config.save_log )
|
||||
ShowInfo("Party Saved (%d - %s)\n", party_id, p->name);
|
||||
return 1;
|
||||
}
|
||||
@ -200,7 +201,7 @@ struct party_data *inter_party_fromsql(int party_id)
|
||||
#endif
|
||||
if( party_id <= 0 )
|
||||
return NULL;
|
||||
|
||||
|
||||
//Load from memory
|
||||
p = (struct party_data*)idb_get(party_db_, party_id);
|
||||
if( p != NULL )
|
||||
@ -209,7 +210,7 @@ struct party_data *inter_party_fromsql(int party_id)
|
||||
p = party_pt;
|
||||
memset(p, 0, sizeof(struct party_data));
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `party_id`, `name`,`exp`,`item`, `leader_id`, `leader_char` FROM `%s` WHERE `party_id`='%d'", party_db, party_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `party_id`, `name`,`exp`,`item`, `leader_id`, `leader_char` FROM `%s` WHERE `party_id`='%d'", schema_config.party_db, party_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return NULL;
|
||||
@ -227,7 +228,7 @@ struct party_data *inter_party_fromsql(int party_id)
|
||||
Sql_FreeResult(sql_handle);
|
||||
|
||||
// Load members
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`,`char_id`,`name`,`base_level`,`last_map`,`online`,`class` FROM `%s` WHERE `party_id`='%d'", char_db, party_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`,`char_id`,`name`,`base_level`,`last_map`,`online`,`class` FROM `%s` WHERE `party_id`='%d'", schema_config.char_db, party_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return NULL;
|
||||
@ -246,7 +247,7 @@ struct party_data *inter_party_fromsql(int party_id)
|
||||
}
|
||||
Sql_FreeResult(sql_handle);
|
||||
|
||||
if( save_log )
|
||||
if( charserv_config.save_log )
|
||||
ShowInfo("Party loaded (%d - %s).\n", party_id, p->party.name);
|
||||
//Add party to memory.
|
||||
CREATE(p, struct party_data, 1);
|
||||
@ -291,7 +292,7 @@ struct party_data* search_partyname(char* str)
|
||||
struct party_data* p = NULL;
|
||||
|
||||
Sql_EscapeStringLen(sql_handle, esc_name, str, safestrnlen(str, NAME_LENGTH));
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `party_id` FROM `%s` WHERE `name`='%s'", party_db, esc_name) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `party_id` FROM `%s` WHERE `name`='%s'", schema_config.party_db, esc_name) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
else if( SQL_SUCCESS == Sql_NextRow(sql_handle) )
|
||||
{
|
||||
@ -370,9 +371,9 @@ static void mapif_party_info(int fd, struct party* p, int char_id)
|
||||
memcpy(WBUFP(buf,8), p, sizeof(struct party));
|
||||
|
||||
if(fd<0)
|
||||
mapif_sendall(buf,WBUFW(buf,2));
|
||||
chmapif_sendall(buf,WBUFW(buf,2));
|
||||
else
|
||||
mapif_send(fd,buf,WBUFW(buf,2));
|
||||
chmapif_send(fd,buf,WBUFW(buf,2));
|
||||
}
|
||||
|
||||
//Whether or not additional party members
|
||||
@ -399,9 +400,9 @@ int mapif_party_optionchanged(int fd,struct party *p,int account_id,int flag)
|
||||
WBUFW(buf,12)=p->item;
|
||||
WBUFB(buf,14)=flag;
|
||||
if(flag==0)
|
||||
mapif_sendall(buf,15);
|
||||
chmapif_sendall(buf,15);
|
||||
else
|
||||
mapif_send(fd,buf,15);
|
||||
chmapif_send(fd,buf,15);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -413,7 +414,7 @@ int mapif_party_withdraw(int party_id,int account_id, int char_id) {
|
||||
WBUFL(buf,2) = party_id;
|
||||
WBUFL(buf,6) = account_id;
|
||||
WBUFL(buf,10) = char_id;
|
||||
mapif_sendall(buf, 14);
|
||||
chmapif_sendall(buf, 14);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -429,7 +430,7 @@ int mapif_party_membermoved(struct party *p,int idx)
|
||||
WBUFW(buf,14) = p->member[idx].map;
|
||||
WBUFB(buf,16) = p->member[idx].online;
|
||||
WBUFW(buf,17) = p->member[idx].lv;
|
||||
mapif_sendall(buf, 19);
|
||||
chmapif_sendall(buf, 19);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -440,7 +441,7 @@ int mapif_party_broken(int party_id,int flag)
|
||||
WBUFW(buf,0)=0x3826;
|
||||
WBUFL(buf,2)=party_id;
|
||||
WBUFB(buf,6)=flag;
|
||||
mapif_sendall(buf,7);
|
||||
chmapif_sendall(buf,7);
|
||||
//printf("int_party: broken %d\n",party_id);
|
||||
return 0;
|
||||
}
|
||||
@ -454,7 +455,7 @@ int mapif_party_message(int party_id,int account_id,char *mes,int len, int sfd)
|
||||
WBUFL(buf,4)=party_id;
|
||||
WBUFL(buf,8)=account_id;
|
||||
memcpy(WBUFP(buf,12),mes,len);
|
||||
mapif_sendallwos(sfd, buf,len+12);
|
||||
chmapif_sendallwos(sfd, buf,len+12);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -472,9 +473,9 @@ int mapif_parse_CreateParty(int fd, char *name, int item, int item2, struct part
|
||||
return 0;
|
||||
}
|
||||
// Check Authorised letters/symbols in the name of the character
|
||||
if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorised
|
||||
if (charserv_config.char_config.char_name_option == 1) { // only letters/symbols in char_name_letters are authorised
|
||||
for (i = 0; i < NAME_LENGTH && name[i]; i++)
|
||||
if (strchr(char_name_letters, name[i]) == NULL) {
|
||||
if (strchr(charserv_config.char_config.char_name_letters, name[i]) == NULL) {
|
||||
if( name[i] == '"' ) { /* client-special-char */
|
||||
normalize_name(name,"\"");
|
||||
mapif_parse_CreateParty(fd,name,item,item2,leader);
|
||||
@ -483,16 +484,16 @@ int mapif_parse_CreateParty(int fd, char *name, int item, int item2, struct part
|
||||
mapif_party_created(fd,leader->account_id,leader->char_id,NULL);
|
||||
return 0;
|
||||
}
|
||||
} else if (char_name_option == 2) { // letters/symbols in char_name_letters are forbidden
|
||||
} else if (charserv_config.char_config.char_name_option == 2) { // letters/symbols in char_name_letters are forbidden
|
||||
for (i = 0; i < NAME_LENGTH && name[i]; i++)
|
||||
if (strchr(char_name_letters, name[i]) != NULL) {
|
||||
if (strchr(charserv_config.char_config.char_name_letters, name[i]) != NULL) {
|
||||
mapif_party_created(fd,leader->account_id,leader->char_id,NULL);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
p = (struct party_data*)aCalloc(1, sizeof(struct party_data));
|
||||
|
||||
|
||||
memcpy(p->party.name,name,NAME_LENGTH);
|
||||
p->party.exp=0;
|
||||
p->party.item=(item?1:0)|(item2?2:0);
|
||||
@ -596,7 +597,7 @@ int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id)
|
||||
p = inter_party_fromsql(party_id);
|
||||
if( p == NULL )
|
||||
{// Party does not exists?
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", char_db, party_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", schema_config.char_db, party_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return 0;
|
||||
}
|
||||
@ -633,7 +634,7 @@ int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id)
|
||||
int_party_check_lv(p);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (party_check_empty(p) == 0)
|
||||
mapif_party_info(-1, &p->party, 0);
|
||||
return 0;
|
||||
@ -648,7 +649,7 @@ int mapif_parse_PartyChangeMap(int fd, int party_id, int account_id, int char_id
|
||||
if (p == NULL)
|
||||
return 0;
|
||||
|
||||
for(i = 0; i < MAX_PARTY &&
|
||||
for(i = 0; i < MAX_PARTY &&
|
||||
(p->party.member[i].account_id != account_id ||
|
||||
p->party.member[i].char_id != char_id); i++);
|
||||
|
||||
@ -662,7 +663,7 @@ int mapif_parse_PartyChangeMap(int fd, int party_id, int account_id, int char_id
|
||||
else
|
||||
p->party.count--;
|
||||
// Even share check situations: Family state (always breaks)
|
||||
// character logging on/off is max/min level (update level range)
|
||||
// character logging on/off is max/min level (update level range)
|
||||
// or character logging on/off has a different level (update level range using new level)
|
||||
if (p->family ||
|
||||
(p->party.member[i].lv <= p->min_lv || p->party.member[i].lv >= p->max_lv) ||
|
||||
@ -727,7 +728,7 @@ int mapif_parse_PartyLeaderChange(int fd,int party_id,int account_id,int char_id
|
||||
|
||||
for (i = 0; i < MAX_PARTY; i++)
|
||||
{
|
||||
if(p->party.member[i].leader)
|
||||
if(p->party.member[i].leader)
|
||||
p->party.member[i].leader = 0;
|
||||
if(p->party.member[i].account_id == account_id &&
|
||||
p->party.member[i].char_id == char_id)
|
||||
@ -799,7 +800,7 @@ int inter_party_CharOnline(int char_id, int party_id)
|
||||
{// Get party_id from the database
|
||||
char* data;
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT party_id FROM `%s` WHERE char_id='%d'", char_db, char_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT party_id FROM `%s` WHERE char_id='%d'", schema_config.char_db, char_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return 0;
|
||||
@ -814,7 +815,7 @@ int inter_party_CharOnline(int char_id, int party_id)
|
||||
}
|
||||
if (party_id == 0)
|
||||
return 0; //No party...
|
||||
|
||||
|
||||
p = inter_party_fromsql(party_id);
|
||||
if(!p) {
|
||||
ShowError("Character %d's party %d not found!\n", char_id, party_id);
|
||||
@ -845,7 +846,7 @@ int inter_party_CharOffline(int char_id, int party_id) {
|
||||
{// Get guild_id from the database
|
||||
char* data;
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT party_id FROM `%s` WHERE char_id='%d'", char_db, char_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT party_id FROM `%s` WHERE char_id='%d'", schema_config.char_db, char_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return 0;
|
||||
@ -860,7 +861,7 @@ int inter_party_CharOffline(int char_id, int party_id) {
|
||||
}
|
||||
if (party_id == 0)
|
||||
return 0; //No party...
|
||||
|
||||
|
||||
//Character has a party, set character offline and check if they were the only member online
|
||||
if ((p = inter_party_fromsql(party_id)) == NULL)
|
||||
return 0;
|
||||
|
@ -32,7 +32,7 @@ int inter_pet_tosql(int pet_id, struct s_pet* p)
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` "
|
||||
"(`class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`) "
|
||||
"VALUES ('%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')",
|
||||
pet_db, p->class_, esc_name, p->account_id, p->char_id, p->level, p->egg_id,
|
||||
schema_config.pet_db, p->class_, esc_name, p->account_id, p->char_id, p->level, p->egg_id,
|
||||
p->equip, p->intimate, p->hungry, p->rename_flag, p->incuvate) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
@ -43,7 +43,7 @@ int inter_pet_tosql(int pet_id, struct s_pet* p)
|
||||
else
|
||||
{// Update pet.
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `class`='%d',`name`='%s',`account_id`='%d',`char_id`='%d',`level`='%d',`egg_id`='%d',`equip`='%d',`intimate`='%d',`hungry`='%d',`rename_flag`='%d',`incuvate`='%d' WHERE `pet_id`='%d'",
|
||||
pet_db, p->class_, esc_name, p->account_id, p->char_id, p->level, p->egg_id,
|
||||
schema_config.pet_db, p->class_, esc_name, p->account_id, p->char_id, p->level, p->egg_id,
|
||||
p->equip, p->intimate, p->hungry, p->rename_flag, p->incuvate, p->pet_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
@ -51,7 +51,7 @@ int inter_pet_tosql(int pet_id, struct s_pet* p)
|
||||
}
|
||||
}
|
||||
|
||||
if (save_log)
|
||||
if (charserv_config.save_log)
|
||||
ShowInfo("Pet saved %d - %s.\n", pet_id, p->name);
|
||||
return 1;
|
||||
}
|
||||
@ -68,7 +68,7 @@ int inter_pet_fromsql(int pet_id, struct s_pet* p)
|
||||
|
||||
//`pet` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`)
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate` FROM `%s` WHERE `pet_id`='%d'", pet_db, pet_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate` FROM `%s` WHERE `pet_id`='%d'", schema_config.pet_db, pet_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return 0;
|
||||
@ -94,7 +94,7 @@ int inter_pet_fromsql(int pet_id, struct s_pet* p)
|
||||
p->hungry = cap_value(p->hungry, 0, 100);
|
||||
p->intimate = cap_value(p->intimate, 0, 1000);
|
||||
|
||||
if( save_log )
|
||||
if( charserv_config.save_log )
|
||||
ShowInfo("Pet loaded (%d - %s).\n", pet_id, p->name);
|
||||
}
|
||||
return 0;
|
||||
@ -114,7 +114,7 @@ void inter_pet_sql_final(void){
|
||||
int inter_pet_delete(int pet_id){
|
||||
ShowInfo("delete pet request: %d...\n",pet_id);
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `pet_id`='%d'", pet_db, pet_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `pet_id`='%d'", schema_config.pet_db, pet_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return 0;
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ struct quest *mapif_quests_fromsql(int char_id, int *count) {
|
||||
|
||||
memset(&tmp_quest, 0, sizeof(struct quest));
|
||||
|
||||
if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT `quest_id`, `state`, `time`, `count1`, `count2`, `count3` FROM `%s` WHERE `char_id`=?", quest_db)
|
||||
if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT `quest_id`, `state`, `time`, `count1`, `count2`, `count3` FROM `%s` WHERE `char_id`=? ", schema_config.quest_db)
|
||||
|| SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0)
|
||||
|| SQL_ERROR == SqlStmt_Execute(stmt)
|
||||
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT, &tmp_quest.quest_id, 0, NULL, NULL)
|
||||
@ -88,7 +88,7 @@ struct quest *mapif_quests_fromsql(int char_id, int *count) {
|
||||
* @return false in case of errors, true otherwise
|
||||
*/
|
||||
bool mapif_quest_delete(int char_id, int quest_id) {
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `quest_id` = '%d' AND `char_id` = '%d'", quest_db, quest_id, char_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `quest_id` = '%d' AND `char_id` = '%d'", schema_config.quest_db, quest_id, char_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return false;
|
||||
@ -105,7 +105,7 @@ bool mapif_quest_delete(int char_id, int quest_id) {
|
||||
* @return false in case of errors, true otherwise
|
||||
*/
|
||||
bool mapif_quest_add(int char_id, struct quest qd) {
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s`(`quest_id`, `char_id`, `state`, `time`, `count1`, `count2`, `count3`) VALUES ('%d', '%d', '%d','%d', '%d', '%d', '%d')", quest_db, qd.quest_id, char_id, qd.state, qd.time, qd.count[0], qd.count[1], qd.count[2]) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s`(`quest_id`, `char_id`, `state`, `time`, `count1`, `count2`, `count3`) VALUES ('%d', '%d', '%d','%d', '%d', '%d', '%d')", schema_config.quest_db, qd.quest_id, char_id, qd.state, qd.time, qd.count[0], qd.count[1], qd.count[2]) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return false;
|
||||
@ -122,7 +122,7 @@ bool mapif_quest_add(int char_id, struct quest qd) {
|
||||
* @return false in case of errors, true otherwise
|
||||
*/
|
||||
bool mapif_quest_update(int char_id, struct quest qd) {
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `state`='%d', `count1`='%d', `count2`='%d', `count3`='%d' WHERE `quest_id` = '%d' AND `char_id` = '%d'", quest_db, qd.state, qd.count[0], qd.count[1], qd.count[2], qd.quest_id, char_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `state`='%d', `count1`='%d', `count2`='%d', `count3`='%d' WHERE `quest_id` = '%d' AND `char_id` = '%d'", schema_config.quest_db, qd.state, qd.count[0], qd.count[1], qd.count[2], qd.quest_id, char_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return false;
|
||||
|
@ -20,7 +20,7 @@
|
||||
/// Save storage data to sql
|
||||
int storage_tosql(int account_id, struct storage_data* p)
|
||||
{
|
||||
memitemdata_to_sql(p->items, MAX_STORAGE, account_id, TABLE_STORAGE);
|
||||
char_memitemdata_to_sql(p->items, MAX_STORAGE, account_id, TABLE_STORAGE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ int storage_fromsql(int account_id, struct storage_data* p)
|
||||
StringBuf_AppendStr(&buf, "SELECT `id`,`nameid`,`amount`,`equip`,`identify`,`refine`,`attribute`,`expire_time`,`bound`,`unique_id`");
|
||||
for( j = 0; j < MAX_SLOTS; ++j )
|
||||
StringBuf_Printf(&buf, ",`card%d`", j);
|
||||
StringBuf_Printf(&buf, " FROM `%s` WHERE `account_id`='%d' ORDER BY `nameid`", storage_db, account_id);
|
||||
StringBuf_Printf(&buf, " FROM `%s` WHERE `account_id`='%d' ORDER BY `nameid`", schema_config.storage_db, account_id);
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, StringBuf_Value(&buf)) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
@ -74,7 +74,7 @@ int storage_fromsql(int account_id, struct storage_data* p)
|
||||
/// Save guild_storage data to sql
|
||||
int guild_storage_tosql(int guild_id, struct guild_storage* p)
|
||||
{
|
||||
memitemdata_to_sql(p->items, MAX_GUILD_STORAGE, guild_id, TABLE_GUILD_STORAGE);
|
||||
char_memitemdata_to_sql(p->items, MAX_GUILD_STORAGE, guild_id, TABLE_GUILD_STORAGE);
|
||||
ShowInfo ("guild storage save to DB - guild: %d\n", guild_id);
|
||||
return 0;
|
||||
}
|
||||
@ -94,7 +94,7 @@ int guild_storage_fromsql(int guild_id, struct guild_storage* p)
|
||||
StringBuf_AppendStr(&buf, "SELECT `id`,`nameid`,`amount`,`equip`,`identify`,`refine`,`attribute`,`bound`,`unique_id`");
|
||||
for( j = 0; j < MAX_SLOTS; ++j )
|
||||
StringBuf_Printf(&buf, ",`card%d`", j);
|
||||
StringBuf_Printf(&buf, " FROM `%s` WHERE `guild_id`='%d' ORDER BY `nameid`", guild_storage_db, guild_id);
|
||||
StringBuf_Printf(&buf, " FROM `%s` WHERE `guild_id`='%d' ORDER BY `nameid`", schema_config.guild_storage_db, guild_id);
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, StringBuf_Value(&buf)) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
@ -142,13 +142,13 @@ void inter_storage_sql_final(void)
|
||||
// Delete char storage
|
||||
int inter_storage_delete(int account_id)
|
||||
{
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id`='%d'", storage_db, account_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id`='%d'", schema_config.storage_db, account_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return 0;
|
||||
}
|
||||
int inter_guild_storage_delete(int guild_id)
|
||||
{
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id`='%d'", guild_storage_db, guild_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id`='%d'", schema_config.guild_storage_db, guild_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return 0;
|
||||
}
|
||||
@ -158,7 +158,7 @@ int inter_guild_storage_delete(int guild_id)
|
||||
|
||||
int mapif_load_guild_storage(int fd,int account_id,int guild_id, char flag)
|
||||
{
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", guild_db, guild_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", schema_config.guild_db, guild_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
else if( Sql_NumRows(sql_handle) > 0 )
|
||||
{// guild exists
|
||||
@ -218,7 +218,7 @@ int mapif_parse_SaveGuildStorage(int fd)
|
||||
}
|
||||
else
|
||||
{
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", guild_db, guild_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", schema_config.guild_db, guild_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
else if( Sql_NumRows(sql_handle) > 0 )
|
||||
{// guild exists
|
||||
@ -263,7 +263,7 @@ int mapif_parse_itembound_retrieve(int fd)
|
||||
StringBuf_AppendStr(&buf, "SELECT `id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`, `bound`");
|
||||
for( j = 0; j < MAX_SLOTS; ++j )
|
||||
StringBuf_Printf(&buf, ", `card%d`", j);
|
||||
StringBuf_Printf(&buf, " FROM `%s` WHERE `char_id`='%d'",inventory_db,char_id);
|
||||
StringBuf_Printf(&buf, " FROM `%s` WHERE `char_id`='%d'",schema_config.inventory_db,char_id);
|
||||
|
||||
stmt = SqlStmt_Malloc(sql_handle);
|
||||
if( SQL_ERROR == SqlStmt_PrepareStr(stmt, StringBuf_Value(&buf))
|
||||
@ -305,7 +305,7 @@ int mapif_parse_itembound_retrieve(int fd)
|
||||
|
||||
//First we delete the character's items
|
||||
StringBuf_Clear(&buf);
|
||||
StringBuf_Printf(&buf, "DELETE FROM `%s` WHERE",inventory_db);
|
||||
StringBuf_Printf(&buf, "DELETE FROM `%s` WHERE",schema_config.inventory_db);
|
||||
for(j=0; j<i; j++) {
|
||||
if( found )
|
||||
StringBuf_AppendStr(&buf, " OR");
|
||||
@ -354,7 +354,7 @@ int mapif_parse_itembound_retrieve(int fd)
|
||||
} while( 0 )
|
||||
|
||||
StringBuf_Clear(&buf);
|
||||
StringBuf_Printf(&buf, "UPDATE `%s` SET ", char_db);
|
||||
StringBuf_Printf(&buf, "UPDATE `%s` SET ", schema_config.char_db);
|
||||
for( j = 0; j < bound_qt; j++ ) {
|
||||
//Equips can be at more than one slot at the same time
|
||||
CHECK_REMOVE(bound_item[j],EQP_HAND_R,weapon);
|
||||
@ -387,7 +387,7 @@ int mapif_parse_itembound_retrieve(int fd)
|
||||
found = false;
|
||||
StringBuf_Clear(&buf);
|
||||
StringBuf_Printf(&buf, "INSERT INTO `%s` (`guild_id`, `nameid`, `amount`, `equip`, `identify`, `refine`,"
|
||||
"`attribute`, `expire_time`, `bound`", guild_storage_db);
|
||||
"`attribute`, `expire_time`, `bound`", schema_config.guild_storage_db);
|
||||
for( s = 0; s < MAX_SLOTS; ++s )
|
||||
StringBuf_Printf(&buf, ", `card%d`", s);
|
||||
StringBuf_AppendStr(&buf, ") VALUES ");
|
||||
@ -422,8 +422,14 @@ int mapif_parse_itembound_retrieve(int fd)
|
||||
//Finally reload storage and tell map we're done
|
||||
mapif_load_guild_storage(fd,aid,guild_id,0);
|
||||
|
||||
//If character is logged in char, disconnect
|
||||
disconnect_player(aid);
|
||||
//If character is logged in char, disconnect,
|
||||
/* @CHECKME [lighta]
|
||||
* I suppose this was an attempt to avoid item duplication if the expelled user reconnect during the operation.
|
||||
* well it's kinda ugly to expel someone like this, so I consider this as a hack.
|
||||
* we better flag them so that they not allowed to reconnect during operation or flag it so we will flush those item on ram with the map ack.
|
||||
* both way seem nicer for player.
|
||||
*/
|
||||
char_disconnect_player(aid);
|
||||
|
||||
//Tell map-server the operation is over and it can unlock the storage
|
||||
mapif_itembound_ack(fd,aid,guild_id);
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include "../common/socket.h"
|
||||
#include "../common/timer.h"
|
||||
#include "char.h"
|
||||
#include "char_logif.h"
|
||||
#include "char_mapif.h"
|
||||
#include "inter.h"
|
||||
#include "int_party.h"
|
||||
#include "int_guild.h"
|
||||
@ -389,7 +391,7 @@ void mapif_parse_accinfo(int fd) {
|
||||
account_id = atoi(query);
|
||||
|
||||
if (account_id < START_ACCOUNT_NUM) { // is string
|
||||
if ( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`,`name`,`class`,`base_level`,`job_level`,`online` FROM `%s` WHERE `name` LIKE '%s' LIMIT 10", char_db, query_esq)
|
||||
if ( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`,`name`,`class`,`base_level`,`job_level`,`online` FROM `%s` WHERE `name` LIKE '%s' LIMIT 10", schema_config.char_db, query_esq)
|
||||
|| Sql_NumRows(sql_handle) == 0 ) {
|
||||
if( Sql_NumRows(sql_handle) == 0 ) {
|
||||
inter_to_fd(fd, u_fd, aid, "No matches were found for your criteria, '%s'",query);
|
||||
@ -523,12 +525,12 @@ int inter_accreg_tosql(int account_id, int char_id, struct accreg* reg, int type
|
||||
switch( type )
|
||||
{
|
||||
case 3: //Char Reg
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `type`=3 AND `char_id`='%d'", reg_db, char_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `type`=3 AND `char_id`='%d'", schema_config.reg_db, char_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
account_id = 0;
|
||||
break;
|
||||
case 2: //Account Reg
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `type`=2 AND `account_id`='%d'", reg_db, account_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `type`=2 AND `account_id`='%d'", schema_config.reg_db, account_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
char_id = 0;
|
||||
break;
|
||||
@ -544,7 +546,7 @@ int inter_accreg_tosql(int account_id, int char_id, struct accreg* reg, int type
|
||||
return 0;
|
||||
|
||||
StringBuf_Init(&buf);
|
||||
StringBuf_Printf(&buf, "INSERT INTO `%s` (`type`,`account_id`,`char_id`,`str`,`value`) VALUES ", reg_db);
|
||||
StringBuf_Printf(&buf, "INSERT INTO `%s` (`type`,`account_id`,`char_id`,`str`,`value`) VALUES ", schema_config.reg_db);
|
||||
|
||||
for( i = 0; i < reg->reg_num; ++i ) {
|
||||
r = ®->reg[i];
|
||||
@ -590,11 +592,11 @@ int inter_accreg_fromsql(int account_id,int char_id, struct accreg *reg, int typ
|
||||
switch( type )
|
||||
{
|
||||
case 3: //char reg
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `str`, `value` FROM `%s` WHERE `type`=3 AND `char_id`='%d'", reg_db, char_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `str`, `value` FROM `%s` WHERE `type`=3 AND `char_id`='%d'", schema_config.reg_db, char_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
break;
|
||||
case 2: //account reg
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `str`, `value` FROM `%s` WHERE `type`=2 AND `account_id`='%d'", reg_db, account_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `str`, `value` FROM `%s` WHERE `type`=2 AND `account_id`='%d'", schema_config.reg_db, account_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
break;
|
||||
case 1: //account2 reg
|
||||
@ -669,7 +671,7 @@ static int inter_config_read(const char* cfgName)
|
||||
else if(!strcmpi(w1,"party_share_level"))
|
||||
party_share_level = (unsigned int)atof(w2);
|
||||
else if(!strcmpi(w1,"log_inter"))
|
||||
log_inter = atoi(w2);
|
||||
charserv_config.log_inter = atoi(w2);
|
||||
else if(!strcmpi(w1,"import"))
|
||||
inter_config_read(w2);
|
||||
}
|
||||
@ -692,7 +694,7 @@ int inter_log(char* fmt, ...)
|
||||
va_end(ap);
|
||||
|
||||
Sql_EscapeStringLen(sql_handle, esc_str, str, strnlen(str, sizeof(str)));
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` (`time`, `log`) VALUES (NOW(), '%s')", interlog_db, esc_str) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` (`time`, `log`) VALUES (NOW(), '%s')", schema_config.interlog_db, esc_str) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
return 0;
|
||||
@ -769,8 +771,7 @@ int inter_mapif_init(int fd)
|
||||
int mapif_broadcast(unsigned char *mes, int len, unsigned long fontColor, short fontType, short fontSize, short fontAlign, short fontY, int sfd)
|
||||
{
|
||||
unsigned char *buf = (unsigned char*)aMalloc((len)*sizeof(unsigned char));
|
||||
if (buf == NULL) return 1;
|
||||
|
||||
|
||||
WBUFW(buf,0) = 0x3800;
|
||||
WBUFW(buf,2) = len;
|
||||
WBUFL(buf,4) = fontColor;
|
||||
@ -779,7 +780,7 @@ int mapif_broadcast(unsigned char *mes, int len, unsigned long fontColor, short
|
||||
WBUFW(buf,12) = fontAlign;
|
||||
WBUFW(buf,14) = fontY;
|
||||
memcpy(WBUFP(buf,16), mes, len - 16);
|
||||
mapif_sendallwos(sfd, buf, len);
|
||||
chmapif_sendallwos(sfd, buf, len);
|
||||
|
||||
aFree(buf);
|
||||
return 0;
|
||||
@ -797,7 +798,7 @@ int mapif_wis_message(struct WisData *wd)
|
||||
memcpy(WBUFP(buf, 8), wd->src, NAME_LENGTH);
|
||||
memcpy(WBUFP(buf,32), wd->dst, NAME_LENGTH);
|
||||
memcpy(WBUFP(buf,56), wd->msg, wd->len);
|
||||
wd->count = mapif_sendall(buf,WBUFW(buf,2));
|
||||
wd->count = chmapif_sendall(buf,WBUFW(buf,2));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -810,7 +811,7 @@ int mapif_wis_end(struct WisData *wd, int flag)
|
||||
WBUFW(buf, 0)=0x3802;
|
||||
memcpy(WBUFP(buf, 2),wd->src,24);
|
||||
WBUFB(buf,26)=flag;
|
||||
mapif_send(wd->fd,buf,27);
|
||||
chmapif_send(wd->fd,buf,27);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -818,7 +819,7 @@ int mapif_wis_end(struct WisData *wd, int flag)
|
||||
static void mapif_account_reg(int fd, unsigned char *src)
|
||||
{
|
||||
WBUFW(src,0)=0x3804; //NOTE: writing to RFIFO
|
||||
mapif_sendallwos(fd, src, WBUFW(src,2));
|
||||
chmapif_sendallwos(fd, src, WBUFW(src,2));
|
||||
}
|
||||
|
||||
// Send the requested account_reg
|
||||
@ -934,7 +935,7 @@ int mapif_parse_WisRequest(int fd)
|
||||
safestrncpy(name, (char*)RFIFOP(fd,28), NAME_LENGTH); //Received name may be too large and not contain \0! [Skotlex]
|
||||
|
||||
Sql_EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `name` FROM `%s` WHERE `name`='%s'", char_db, esc_name) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `name` FROM `%s` WHERE `name`='%s'", schema_config.char_db, esc_name) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
// search if character exists before to ask all map-servers
|
||||
@ -944,7 +945,7 @@ int mapif_parse_WisRequest(int fd)
|
||||
WBUFW(buf, 0) = 0x3802;
|
||||
memcpy(WBUFP(buf, 2), RFIFOP(fd, 4), NAME_LENGTH);
|
||||
WBUFB(buf,26) = 1; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
|
||||
mapif_send(fd, buf, 27);
|
||||
chmapif_send(fd, buf, 27);
|
||||
}
|
||||
else
|
||||
{// Character exists. So, ask all map-servers
|
||||
@ -959,7 +960,7 @@ int mapif_parse_WisRequest(int fd)
|
||||
WBUFW(buf, 0) = 0x3802;
|
||||
memcpy(WBUFP(buf, 2), RFIFOP(fd, 4), NAME_LENGTH);
|
||||
WBUFB(buf,26) = 1; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
|
||||
mapif_send(fd, buf, 27);
|
||||
chmapif_send(fd, buf, 27);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1014,7 +1015,7 @@ int mapif_parse_WisToGM(int fd)
|
||||
|
||||
memcpy(WBUFP(buf,0), RFIFOP(fd,0), RFIFOW(fd,2));
|
||||
WBUFW(buf, 0) = 0x3803;
|
||||
mapif_sendall(buf, RFIFOW(fd,2));
|
||||
chmapif_sendall(buf, RFIFOW(fd,2));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1034,7 +1035,7 @@ int mapif_parse_Registry(int fd)
|
||||
max = ACCOUNT_REG_NUM;
|
||||
break;
|
||||
case 1: //Account2 registry, must be sent over to login server.
|
||||
return save_accreg2(RFIFOP(fd,4), RFIFOW(fd,2)-4);
|
||||
return chlogif_save_accreg2(RFIFOP(fd,4), RFIFOW(fd,2)-4);
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
@ -1061,7 +1062,7 @@ int mapif_parse_RegistryRequest(int fd)
|
||||
//Load Account Registry
|
||||
if (RFIFOB(fd,11)) mapif_account_reg_reply(fd,RFIFOL(fd,2),RFIFOL(fd,6),2);
|
||||
//Ask Login Server for Account2 values.
|
||||
if (RFIFOB(fd,10)) request_accreg2(RFIFOL(fd,2),RFIFOL(fd,6));
|
||||
if (RFIFOB(fd,10)) chlogif_request_accreg2(RFIFOL(fd,2),RFIFOL(fd,6));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1089,15 +1090,15 @@ int mapif_parse_NameChangeRequest(int fd)
|
||||
name = (char*)RFIFOP(fd,11);
|
||||
|
||||
// Check Authorised letters/symbols in the name
|
||||
if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorised
|
||||
if (charserv_config.char_config.char_name_option == 1) { // only letters/symbols in char_name_letters are authorised
|
||||
for (i = 0; i < NAME_LENGTH && name[i]; i++)
|
||||
if (strchr(char_name_letters, name[i]) == NULL) {
|
||||
if (strchr(charserv_config.char_config.char_name_letters, name[i]) == NULL) {
|
||||
mapif_namechange_ack(fd, account_id, char_id, type, 0, name);
|
||||
return 0;
|
||||
}
|
||||
} else if (char_name_option == 2) { // letters/symbols in char_name_letters are forbidden
|
||||
} else if (charserv_config.char_config.char_name_option == 2) { // letters/symbols in char_name_letters are forbidden
|
||||
for (i = 0; i < NAME_LENGTH && name[i]; i++)
|
||||
if (strchr(char_name_letters, name[i]) != NULL) {
|
||||
if (strchr(charserv_config.char_config.char_name_letters, name[i]) != NULL) {
|
||||
mapif_namechange_ack(fd, account_id, char_id, type, 0, name);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,3 +1,12 @@
|
||||
/**
|
||||
* @file cli.c
|
||||
* Module purpose is to handle the console (cli=console line input) while the servers launch and run.
|
||||
* This contains functions common to all servers, but then dispatches them to a specific parser on each server.
|
||||
* Licensed under GNU GPL.
|
||||
* For more information, see LICENCE in the main folder.
|
||||
* @author rAthena Dev Team
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
@ -29,14 +38,16 @@ char* LOGIN_CONF_NAME;
|
||||
char* LAN_CONF_NAME; //char-login
|
||||
char* MSG_CONF_NAME_EN; //all
|
||||
|
||||
/*
|
||||
* Function to check if specified option have an argument follow it
|
||||
* return
|
||||
/**
|
||||
* Function to check if the specified option has an argument following it.
|
||||
* @param option: actual args string
|
||||
* @param i: index of current args
|
||||
* @param argc: arguments count
|
||||
* @return
|
||||
* false : no other args found, and throw a warning
|
||||
* true : something following us
|
||||
*/
|
||||
bool opt_has_next_value(const char* option, int i, int argc)
|
||||
{
|
||||
bool opt_has_next_value(const char* option, int i, int argc){
|
||||
if (i >= argc - 1) {
|
||||
ShowWarning("Missing value for option '%s'.\n", option);
|
||||
return false;
|
||||
@ -45,11 +56,12 @@ bool opt_has_next_value(const char* option, int i, int argc)
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Display some info about emulator such as
|
||||
/**
|
||||
* Display some information about the emulator, such as:
|
||||
* svn version
|
||||
* website/forum adresse
|
||||
* website/forum address
|
||||
* irc hangout
|
||||
* @param do_exit: terminate execution ?
|
||||
*/
|
||||
void display_versionscreen(bool do_exit)
|
||||
{
|
||||
@ -68,16 +80,18 @@ void display_versionscreen(bool do_exit)
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the option specify in command line
|
||||
* and assign the confs used by the different server
|
||||
* exit on failure or return true
|
||||
/**
|
||||
* Read the option specified in the command line
|
||||
* and assign the confs used by the different servers.
|
||||
* @TODO remove and place into csnlif of different serv
|
||||
* @param argc: arguments count (from main)
|
||||
* @param argv: arguments values (from main)
|
||||
* @return true or exit on failure
|
||||
*/
|
||||
int cli_get_options(int argc, char ** argv)
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 1; i < argc; i++) {
|
||||
const char* arg = argv[i];
|
||||
int cli_get_options(int argc, char ** argv) {
|
||||
int i = 0;
|
||||
for (i = 1; i < argc; i++) {
|
||||
const char* arg = argv[i];
|
||||
|
||||
if (arg[0] != '-' && (arg[0] != '/' || arg[1] == '-')) {// -, -- and /
|
||||
ShowError("Unknown option '%s'.\n", argv[i]);
|
||||
@ -163,17 +177,29 @@ int cli_get_options(int argc, char ** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int cli_hasevent(){
|
||||
/**
|
||||
* Detect if the console has some input to be read.
|
||||
* @return true if event, else false
|
||||
*/
|
||||
bool cli_hasevent(){
|
||||
#ifdef WIN32
|
||||
return _kbhit();
|
||||
return (_kbhit()!=0);
|
||||
#else
|
||||
struct pollfd fds;
|
||||
fds.fd = 0; /* this is STDIN */
|
||||
fds.events = POLLIN;
|
||||
return poll(&fds, 1, 0);
|
||||
return (poll(&fds, 1, 0)>0);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Timered function to check if the console has a new event to be read.
|
||||
* @param tid: timer id
|
||||
* @param tick: tick of execution
|
||||
* @param id: user account id
|
||||
* @param data: unused
|
||||
* @return 0
|
||||
*/
|
||||
int parse_console_timer(int tid, unsigned int tick, int id, intptr_t data) {
|
||||
char buf[MAX_CONSOLE_IN]; //max cmd atm is 63+63+63+3+3
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
/*
|
||||
* File: cli.h
|
||||
* Author: lighta
|
||||
*
|
||||
* Created on February 21, 2013, 6:15 PM
|
||||
/**
|
||||
* @file cli.h
|
||||
* Module purpose is to handle the console (cli=console line input) while the servers launch and run.
|
||||
* This contains functions common to all servers, but then dispatches them to a specific parser on each server.
|
||||
* Licensed under GNU GPL.
|
||||
* For more information, see LICENCE in the main folder.
|
||||
* @author rAthena Dev Team
|
||||
*/
|
||||
|
||||
#ifndef CLI_H
|
||||
@ -32,6 +34,9 @@ extern "C" {
|
||||
extern char* MSG_CONF_NAME_EN; //all
|
||||
|
||||
extern void display_helpscreen(bool exit);
|
||||
bool cli_hasevent();
|
||||
void display_versionscreen(bool do_exit);
|
||||
bool opt_has_next_value(const char* option, int i, int argc);
|
||||
int cli_get_options(int argc, char ** argv);
|
||||
int parse_console_timer(int tid, unsigned int tick, int id, intptr_t data);
|
||||
extern int parse_console(const char* buf); //particular for each serv
|
||||
|
@ -136,7 +136,7 @@ bool evdp_outgoingconnection_established(int32 fd, EVDP_DATA *ep);
|
||||
* the connection must be already added (as client or listener)
|
||||
*
|
||||
*
|
||||
* @return sucess indicator
|
||||
* @return success indicator
|
||||
*/
|
||||
bool evdp_writable_add(int32 fd, EVDP_DATA *ep);
|
||||
|
||||
|
@ -115,6 +115,8 @@ void aFree_(void *p, const char *file, int line, const char *func)
|
||||
// ShowMessage("%s:%d: in func %s: aFree %p\n",file,line,func,p);
|
||||
if (p)
|
||||
FREE(p, file, line, func);
|
||||
|
||||
p = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -89,6 +89,7 @@
|
||||
//For character names, title names, guilds, maps, etc.
|
||||
//Includes null-terminator as it is the length of the array.
|
||||
#define NAME_LENGTH (23 + 1)
|
||||
#define PASSWD_LENGTH (32+1)
|
||||
//For item names, which tend to have much longer names.
|
||||
#define ITEM_NAME_LENGTH 50
|
||||
//For Map Names, which the client considers to be 16 in length including the .gat extension
|
||||
|
@ -51,6 +51,7 @@ int add_timer_func_list(TimerFunc func, char* name);
|
||||
|
||||
unsigned long get_uptime(void);
|
||||
|
||||
//transform a timestamp to string
|
||||
const char* timestamp2string(char* str, size_t size, time_t timestamp, const char* format);
|
||||
void split_time(int time, int* year, int* month, int* day, int* hour, int* minute, int* second);
|
||||
double solve_time(char* modif_p);
|
||||
|
Loading…
x
Reference in New Issue
Block a user