Initial work for char server to C++ (#2567)

* Initial work for char server to C++

* Changes suggested from @Lemongrass3110

* Removes unwanted beginning white spaces.
This commit is contained in:
lighta 2017-11-06 22:40:35 -04:00 committed by GitHub
parent 6decf6c6d0
commit 24b3509e53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
40 changed files with 403 additions and 449 deletions

View File

@ -9,8 +9,7 @@ set( CHAR_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" )
#
if( BUILD_SERVERS )
message( STATUS "Creating target char-server" )
file(GLOB CHAR_HEADERS ${CHAR_SOURCE_DIR}/*.h)
file(GLOB CHAR_SOURCES_C ${CHAR_SOURCE_DIR}/*.c)
file(GLOB CHAR_HEADERS ${CHAR_SOURCE_DIR}/*.hpp)
file(GLOB CHAR_SOURCES_CXX ${CHAR_SOURCE_DIR}/*.cpp)
set(CHAR_SOURCES ${CHAR_SOURCES_C} ${CHAR_SOURCES_CXX})
#message( STATUS "CHAR_SOURCES="${CHAR_SOURCES})

View File

@ -14,9 +14,9 @@ LIBCONFIG_INCLUDE = -I../../3rdparty/libconfig
COMMON_OBJ = ../common/obj/sql.o
COMMON_H = ../common/sql.h
CHAR_OBJ = $(shell ls *.c | sed -e "s/\.c/\.o/g") $(shell ls *.cpp | sed -e "s/\.cpp/\.o/g")
CHAR_OBJ = $(shell ls *.cpp | sed -e "s/\.cpp/\.o/g")
CHAR_DIR_OBJ = $(CHAR_OBJ:%=obj/%)
CHAR_H = $(shell ls ../char/*.h)
CHAR_H = $(shell ls ../char/*.hpp)
YAML_CPP_OBJ = $(shell find ../../3rdparty/yaml-cpp/ -type f -name "*.cpp" | sed -e "s/\.cpp/\.o/g" )
YAML_CPP_DIR_OBJ = $(YAML_CPP_OBJ:%=obj/%)

View File

@ -159,45 +159,43 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="char.h" />
<ClInclude Include="char_clif.h" />
<ClInclude Include="char_cnslif.h" />
<ClInclude Include="char_logif.h" />
<ClInclude Include="char_mapif.h" />
<ClInclude Include="inter.h" />
<ClInclude Include="int_achievement.h" />
<ClInclude Include="int_auction.h" />
<ClInclude Include="int_clan.h" />
<ClInclude Include="int_elemental.h" />
<ClInclude Include="int_guild.h" />
<ClInclude Include="int_homun.h" />
<ClInclude Include="int_mail.h" />
<ClInclude Include="int_mercenary.h" />
<ClInclude Include="int_party.h" />
<ClInclude Include="int_pet.h" />
<ClInclude Include="int_quest.h" />
<ClInclude Include="int_storage.h" />
<ClInclude Include="char.hpp" />
<ClInclude Include="char_clif.hpp" />
<ClInclude Include="char_cnslif.hpp" />
<ClInclude Include="char_logif.hpp" />
<ClInclude Include="char_mapif.hpp" />
<ClInclude Include="inter.hpp" />
<ClInclude Include="int_achievement.hpp" />
<ClInclude Include="int_auction.hpp" />
<ClInclude Include="int_clan.hpp" />
<ClInclude Include="int_elemental.hpp" />
<ClInclude Include="int_guild.hpp" />
<ClInclude Include="int_homun.hpp" />
<ClInclude Include="int_mail.hpp" />
<ClInclude Include="int_mercenary.hpp" />
<ClInclude Include="int_party.hpp" />
<ClInclude Include="int_pet.hpp" />
<ClInclude Include="int_quest.hpp" />
<ClInclude Include="int_storage.hpp" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="char.cpp">
<CompileAs>CompileAsCpp</CompileAs>
</ClCompile>
<ClCompile Include="char_clif.c" />
<ClCompile Include="char_cnslif.c" />
<ClCompile Include="char_logif.c" />
<ClCompile Include="char_mapif.c" />
<ClCompile Include="char.cpp" />
<ClCompile Include="char_clif.cpp" />
<ClCompile Include="char_cnslif.cpp" />
<ClCompile Include="char_logif.cpp" />
<ClCompile Include="char_mapif.cpp" />
<ClCompile Include="inter.cpp" />
<ClCompile Include="int_achievement.c" />
<ClCompile Include="int_auction.c" />
<ClCompile Include="int_clan.c" />
<ClCompile Include="int_elemental.c" />
<ClCompile Include="int_guild.c" />
<ClCompile Include="int_homun.c" />
<ClCompile Include="int_mail.c" />
<ClCompile Include="int_mercenary.c" />
<ClCompile Include="int_party.c" />
<ClCompile Include="int_pet.c" />
<ClCompile Include="int_quest.c" />
<ClCompile Include="int_achievement.cpp" />
<ClCompile Include="int_auction.cpp" />
<ClCompile Include="int_clan.cpp" />
<ClCompile Include="int_elemental.cpp" />
<ClCompile Include="int_guild.cpp" />
<ClCompile Include="int_homun.cpp" />
<ClCompile Include="int_mail.cpp" />
<ClCompile Include="int_mercenary.cpp" />
<ClCompile Include="int_party.cpp" />
<ClCompile Include="int_pet.cpp" />
<ClCompile Include="int_quest.cpp" />
<ClCompile Include="int_storage.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -11,58 +11,58 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="char.h">
<ClInclude Include="char.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="char_clif.h">
<ClInclude Include="char_clif.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="char_cnslif.h">
<ClInclude Include="char_cnslif.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="char_logif.h">
<ClInclude Include="char_logif.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="char_mapif.h">
<ClInclude Include="char_mapif.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="int_achievement.h">
<ClInclude Include="int_achievement.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="int_auction.h">
<ClInclude Include="int_auction.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="int_elemental.h">
<ClInclude Include="int_elemental.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="int_guild.h">
<ClInclude Include="int_guild.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="int_homun.h">
<ClInclude Include="int_homun.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="int_mail.h">
<ClInclude Include="int_mail.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="int_mercenary.h">
<ClInclude Include="int_mercenary.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="int_party.h">
<ClInclude Include="int_party.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="int_pet.h">
<ClInclude Include="int_pet.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="int_quest.h">
<ClInclude Include="int_quest.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="int_storage.h">
<ClInclude Include="int_storage.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="inter.h">
<ClInclude Include="inter.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="int_clan.h">
<ClInclude Include="int_clan.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
@ -70,46 +70,46 @@
<ClCompile Include="char.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="char_clif.c">
<ClCompile Include="char_clif.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="char_cnslif.c">
<ClCompile Include="char_cnslif.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="char_logif.c">
<ClCompile Include="char_logif.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="char_mapif.c">
<ClCompile Include="char_mapif.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="int_achievement.c">
<ClCompile Include="int_achievement.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="int_auction.c">
<ClCompile Include="int_auction.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="int_elemental.c">
<ClCompile Include="int_elemental.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="int_guild.c">
<ClCompile Include="int_guild.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="int_homun.c">
<ClCompile Include="int_homun.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="int_mail.c">
<ClCompile Include="int_mail.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="int_mercenary.c">
<ClCompile Include="int_mercenary.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="int_party.c">
<ClCompile Include="int_party.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="int_pet.c">
<ClCompile Include="int_pet.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="int_quest.c">
<ClCompile Include="int_quest.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="int_storage.cpp">
@ -118,7 +118,7 @@
<ClCompile Include="inter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="int_clan.c">
<ClCompile Include="int_clan.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>

View File

@ -2,6 +2,7 @@
// For more information, see LICENCE in the main folder
#pragma warning(disable:4800)
#include "char.hpp"
#include <time.h>
#include <stdarg.h>
@ -21,18 +22,19 @@
#include "../common/strlib.h"
#include "../common/timer.h"
#include "../common/cli.h"
#include "int_guild.h"
#include "int_homun.h"
#include "int_mail.h"
#include "int_mercenary.h"
#include "int_elemental.h"
#include "int_party.h"
#include "int_storage.h"
#include "inter.h"
#include "char_logif.h"
#include "char_mapif.h"
#include "char_cnslif.h"
#include "char_clif.h"
#include "int_guild.hpp"
#include "int_homun.hpp"
#include "int_mail.hpp"
#include "int_mercenary.hpp"
#include "int_elemental.hpp"
#include "int_party.hpp"
#include "int_storage.hpp"
#include "inter.hpp"
#include "char_logif.hpp"
#include "char_mapif.hpp"
#include "char_cnslif.hpp"
#include "char_clif.hpp"
//definition of exported var declared in .h
int login_fd=-1; //login file descriptor
@ -215,7 +217,7 @@ int char_db_setoffline(DBKey key, DBData *data, va_list ap) {
/**
* @see DBApply
*/
static int char_db_kickoffline(DBKey key, DBData *data, va_list ap){
int char_db_kickoffline(DBKey key, DBData *data, va_list ap){
struct online_char_data* character = (struct online_char_data*)db_data2ptr(data);
int server_id = va_arg(ap, int);
@ -259,7 +261,7 @@ void char_set_all_offline_sql(void){
/**
* @see DBCreateData
*/
static DBData char_create_charstatus(DBKey key, va_list args) {
DBData char_create_charstatus(DBKey key, va_list args) {
struct mmo_charstatus *cp;
cp = (struct mmo_charstatus *) aCalloc(1,sizeof(struct mmo_charstatus));
cp->char_id = key.i;
@ -2178,7 +2180,7 @@ int char_chardb_waiting_disconnect(int tid, unsigned int tick, int id, intptr_t
/**
* @see DBApply
*/
static int char_online_data_cleanup_sub(DBKey key, DBData *data, va_list ap)
int char_online_data_cleanup_sub(DBKey key, DBData *data, va_list ap)
{
struct online_char_data *character= (struct online_char_data *)db_data2ptr(data);
if (character->fd != -1)
@ -2191,12 +2193,12 @@ static int char_online_data_cleanup_sub(DBKey key, DBData *data, va_list ap)
return 0;
}
static int char_online_data_cleanup(int tid, unsigned int tick, int id, intptr_t data){
int char_online_data_cleanup(int tid, unsigned int tick, int id, intptr_t data){
online_char_db->foreach(online_char_db, char_online_data_cleanup_sub);
return 0;
}
static int char_clan_member_cleanup( int tid, unsigned int tick, int id, intptr_t data ){
int char_clan_member_cleanup( int tid, unsigned int tick, int id, intptr_t data ){
// Auto removal is disabled
if( charserv_config.clan_remove_inactive_days <= 0 ){
return 0;
@ -2782,7 +2784,7 @@ void char_set_defaults(){
* @param start: Start point reference
* @param count: Start point count reference
*/
static void char_config_split_startpoint(char *w1_value, char *w2_value, struct point start_point[MAX_STARTPOINT], short *count)
void char_config_split_startpoint(char *w1_value, char *w2_value, struct point start_point[MAX_STARTPOINT], short *count)
{
char *lineitem, **fields;
int i = 0, fields_length = 3 + 1;
@ -2827,7 +2829,7 @@ static void char_config_split_startpoint(char *w1_value, char *w2_value, struct
* @param w2_value: Value from w2
* @param start: Start item reference
*/
static void char_config_split_startitem(char *w1_value, char *w2_value, struct startitem start_items[MAX_STARTITEM])
void char_config_split_startitem(char *w1_value, char *w2_value, struct startitem start_items[MAX_STARTITEM])
{
char *lineitem, **fields;
int i = 0, fields_length = 3 + 1;
@ -3064,7 +3066,7 @@ bool char_config_read(const char* cfgName, bool normal){
/**
* Checks for values out of range.
*/
static void char_config_adjust() {
void char_config_adjust() {
#if PACKETVER < 20100803
if (charserv_config.char_config.char_del_option&CHAR_DEL_BIRTHDATE) {
ShowWarning("conf/char_athena.conf:char_del_option birthdate is enabled but it requires PACKETVER 2010-08-03 or newer, defaulting to email...\n");

View File

@ -4,10 +4,6 @@
#ifndef _CHAR_SQL_H_
#define _CHAR_SQL_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "../config/core.h"
#include "../common/core.h" // CORE_ST_LAST
#include "../common/msg_conf.h"
@ -96,7 +92,7 @@ extern struct Schema_Config schema_config;
#if PACKETVER_SUPPORTS_PINCODE
/// Pincode system
enum pincode_state {
enum pincode_state : uint8 {
PINCODE_OK = 0,
PINCODE_ASK = 1,
PINCODE_NOTSET = 2,
@ -320,13 +316,10 @@ void char_set_session_flag_(int account_id, int val, bool set);
#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);
int char_msg_config_read(const char *cfgName);
const char* char_msg_txt(int msg_number);
void char_do_final_msg(void);
bool char_config_read(const char* cfgName, bool normal);
#ifdef __cplusplus
}
#endif
#endif /* _CHAR_SQL_H_ */

View File

@ -1,6 +1,11 @@
// Copyright (c) rAthena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
#include "char_clif.hpp"
#include <stdlib.h>
#include <string.h>
#include "../common/mmo.h"
#include "../common/socket.h"
#include "../common/sql.h"
@ -11,13 +16,11 @@
#include "../common/strlib.h"
#include "../common/utils.h"
#include "../common/timer.h"
#include "inter.h"
#include "char.h"
#include "char_logif.h"
#include "char_mapif.h"
#include "char_clif.h"
#include "inter.hpp"
#include "char.hpp"
#include "char_logif.hpp"
#include "char_mapif.hpp"
#include <stdlib.h>
#if PACKETVER_SUPPORTS_PINCODE
bool pincode_allowed( char* pincode );
@ -332,7 +335,7 @@ int chclif_mmo_send006b(int fd, struct char_session_data* sd){
#endif
if (charserv_config.save_log)
ShowInfo("Loading Char Data ("CL_BOLD"%d"CL_RESET")\n",sd->account_id);
ShowInfo("Loading Char Data (" CL_BOLD "%d" CL_RESET ")\n",sd->account_id);
j = 24 + offset; // offset
WFIFOHEAD(fd,j + MAX_CHARS*MAX_CHAR_BUF);
@ -355,7 +358,7 @@ int chclif_mmo_send006b(int fd, struct char_session_data* sd){
//----------------------------------------
void chclif_mmo_send082d(int fd, struct char_session_data* sd) {
if (charserv_config.save_log)
ShowInfo("Loading Char Data ("CL_BOLD"%d"CL_RESET")\n",sd->account_id);
ShowInfo("Loading Char Data (" CL_BOLD "%d" CL_RESET ")\n",sd->account_id);
WFIFOHEAD(fd,29);
WFIFOW(fd,0) = 0x82d;
WFIFOW(fd,2) = 29;
@ -444,7 +447,7 @@ void chclif_char_delete2_ack(int fd, uint32 char_id, uint32 result, time_t delet
void chclif_char_delete2_accept_ack(int fd, uint32 char_id, uint32 result) {
#if PACKETVER >= 20130000
if(result == 1 ){
chclif_mmo_char_send(fd, session[fd]->session_data);
chclif_mmo_char_send(fd, (char_session_data*)session[fd]->session_data);
}
#endif
@ -536,7 +539,7 @@ int chclif_parse_char_delete2_req(int fd, struct char_session_data* sd) {
* @param flag Delete flag
* @return true:Success, false:Failure
**/
static bool chclif_delchar_check(struct char_session_data *sd, char *delcode, uint8 flag) {
bool chclif_delchar_check(struct char_session_data *sd, char *delcode, uint8 flag) {
// E-Mail check
if (flag&CHAR_DEL_EMAIL && (
!stricmp(delcode, sd->email) || //email does not match or
@ -544,7 +547,7 @@ static bool chclif_delchar_check(struct char_session_data *sd, char *delcode, ui
!stricmp("a@a.com", sd->email) && //it is default email and
!strcmp("", delcode) //user sent an empty email
))) {
ShowInfo(""CL_RED"Char Deleted"CL_RESET" "CL_GREEN"(E-Mail)"CL_RESET".\n");
ShowInfo("" CL_RED "Char Deleted" CL_RESET " " CL_GREEN "(E-Mail)" CL_RESET ".\n");
return true;
}
// Birthdate (YYMMDD)
@ -554,7 +557,7 @@ static bool chclif_delchar_check(struct char_session_data *sd, char *delcode, ui
!strcmp("",sd->birthdate) && // it is default birthdate and
!strcmp("",delcode) // user sent an empty birthdate
))) {
ShowInfo(""CL_RED"Char Deleted"CL_RESET" "CL_GREEN"(Birthdate)"CL_RESET".\n");
ShowInfo("" CL_RED "Char Deleted" CL_RESET " " CL_GREEN "(Birthdate)" CL_RESET ".\n");
return true;
}
return false;
@ -568,7 +571,7 @@ int chclif_parse_char_delete2_accept(int fd, struct char_session_data* sd) {
uint32 char_id;
char_id = RFIFOL(fd,2);
ShowInfo(CL_RED"Request Char Deletion: "CL_GREEN"%d (%d)"CL_RESET"\n", sd->account_id, char_id);
ShowInfo(CL_RED "Request Char Deletion: " CL_GREEN "%d (%d)" CL_RESET "\n", sd->account_id, char_id);
// construct "YY-MM-DD"
birthdate[0] = RFIFOB(fd,6);
@ -993,7 +996,7 @@ int chclif_parse_delchar(int fd,struct char_session_data* sd, int cmd){
char email[40];
uint32 cid = RFIFOL(fd,2);
ShowInfo(CL_RED"Request Char Deletion: "CL_GREEN"%u (%u)"CL_RESET"\n", sd->account_id, cid);
ShowInfo(CL_RED "Request Char Deletion: " CL_GREEN "%u (%u)" CL_RESET "\n", sd->account_id, cid);
memcpy(email, RFIFOP(fd,6), 40);
RFIFOSKIP(fd,( cmd == 0x68) ? 46 : 56);
@ -1327,7 +1330,7 @@ int chclif_parse(int fd) {
case 0x9a1: next=chclif_parse_req_charlist(fd,sd); break;
// unknown packet received
default:
ShowError("parse_char: Received unknown packet "CL_WHITE"0x%x"CL_RESET" from ip '"CL_WHITE"%s"CL_RESET"'! Disconnecting!\n", RFIFOW(fd,0), ip2str(ipl, NULL));
ShowError("parse_char: Received unknown packet " CL_WHITE "0x%x" CL_RESET " from ip '" CL_WHITE "%s" CL_RESET "'! Disconnecting!\n", RFIFOW(fd,0), ip2str(ipl, NULL));
set_eof(fd);
return 0;
}

View File

@ -1,18 +1,15 @@
/*
* File: char_clif.h
* Author: lighta
*
* Created on June 15, 2013, 12:06 PM
*/
// Copyright (c) rAthena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
#ifndef CHAR_CLIF_H
#define CHAR_CLIF_H
#include "char.h"
#ifdef __cplusplus
extern "C" {
#endif
//#include "char.h"
#include "../common/cbasetypes.h"
#include "../common/timer.h" //time_t
struct char_session_data;
enum pincode_state : uint8;
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);
@ -57,9 +54,5 @@ void chclif_block_character( int fd, struct char_session_data* sd);
int chclif_parse(int fd);
#ifdef __cplusplus
}
#endif
#endif /* CHAR_CLIF_H */

View File

@ -1,16 +1,16 @@
// Copyright (c) rAthena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
#include "char_cnslif.hpp"
#include <stdlib.h>
#include <string.h>
#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 <stdlib.h>
#include <string.h>
#include "char.hpp"
/*======================================================
* Login-Server help option info
@ -75,7 +75,7 @@ int cnslif_parse(const char* buf)
runflag = 0;
}
else if( strcmpi("alive", command) == 0 || strcmpi("status", command) == 0 )
ShowInfo(CL_CYAN"Console: "CL_BOLD"I'm Alive."CL_RESET"\n");
ShowInfo(CL_CYAN "Console: " CL_BOLD "I'm Alive." CL_RESET "\n");
else if( strcmpi("reloadconf", command) == 0 ) {
ShowInfo("Reloading config file \"%s\"\n", CHAR_CONF_NAME);
char_config_read(CHAR_CONF_NAME, false);

View File

@ -1,22 +1,17 @@
/*
* File: char_cnslif.h
* Author: lighta
*
* Created on June 15, 2013, 12:07 PM
*/
// Copyright (c) rAthena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
#ifndef CHAR_CNSLIF_H
#define CHAR_CNSLIF_H
int cnslif_parse(const char* buf);
void do_init_chcnslif(void);
#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

View File

@ -1,5 +1,9 @@
// Copyright (c) rAthena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
#include "char_logif.hpp"
#include <stdlib.h>
#include <string.h>
#include "../common/socket.h"
#include "../common/timer.h"
@ -7,14 +11,13 @@
#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 <stdlib.h>
#include "inter.hpp"
#include "int_guild.hpp"
#include "char.hpp"
#include "char_clif.hpp"
#include "char_mapif.hpp"
//early declaration
void chlogif_on_ready(void);
@ -83,7 +86,7 @@ void chlogif_pincode_start(int fd, struct char_session_data* sd){
* 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) {
int chlogif_send_acc_tologin_sub(DBKey key, DBData *data, va_list ap) {
struct online_char_data* character = (struct online_char_data*)db_data2ptr(data);
int* i = va_arg(ap, int*);
if(character->server > -1) {
@ -396,7 +399,7 @@ int chlogif_parse_keepalive(int fd, struct char_session_data* sd){
*/
void chlogif_parse_change_sex_sub(int sex, int acc, int char_id, int class_, int guild_id)
{
// job modification
// job modification //@TODO switch would be faster
if (class_ == JOB_BARD || class_ == JOB_DANCER)
class_ = (sex == SEX_MALE ? JOB_BARD : JOB_DANCER);
else if (class_ == JOB_CLOWN || class_ == JOB_GYPSY)

View File

@ -1,18 +1,13 @@
/*
* File: char_logif.h
* Author: lighta
*
* Created on June 15, 2013, 12:05 PM
*/
// Copyright (c) rAthena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
#ifndef CHAR_LOGIF_H
#define CHAR_LOGIF_H
#include "char.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "../common/cbasetypes.h"
//#include "char.hpp"
struct char_session_data;
#if PACKETVER_SUPPORTS_PINCODE
void chlogif_pincode_notifyLoginPinError( uint32 account_id );
@ -61,9 +56,6 @@ void do_final_chlogif(void);
#define loginif_check(a) { if(!chlogif_isconnected()) return a; }
#ifdef __cplusplus
}
#endif
#endif /* CHAR_LOGIF_H */

View File

@ -6,18 +6,19 @@
* @author Athena Dev Teams originally in login.c
* @author rAthena Dev Team
*/
#include "char_mapif.hpp"
#include <stdlib.h>
#include <string.h> //memcpy
#include "../common/socket.h"
#include "../common/sql.h"
#include "../common/malloc.h"
#include "../common/showmsg.h"
#include "../common/strlib.h"
#include "inter.h"
#include "char.h"
#include "char_logif.h"
#include "char_mapif.h"
#include "inter.hpp"
#include "char.hpp"
#include "char_logif.hpp"
#include <stdlib.h>
/**
* Packet send to all map-servers, attach to ourself
@ -167,7 +168,7 @@ void chmapif_sendall_playercount(int users){
* HZ 0x2afb <size>.W <status>.B <name>.24B <mapname>.11B <map_x>.W <map_y>.W
* @param fd
**/
static void chmapif_send_misc(int fd) {
void chmapif_send_misc(int fd) {
uint16 offs = 5;
unsigned char buf[45];
@ -195,7 +196,7 @@ static void chmapif_send_misc(int fd) {
* @param map_id
* @param count Number of map from new map-server has
**/
static void chmapif_send_maps(int fd, int map_id, int count, unsigned char *mapbuf) {
void chmapif_send_maps(int fd, int map_id, int count, unsigned char *mapbuf) {
uint16 x;
if (count == 0) {

View File

@ -10,9 +10,7 @@
#ifndef CHAR_MAPIF_H
#define CHAR_MAPIF_H
#ifdef __cplusplus
extern "C" {
#endif
#include "../common/cbasetypes.h"
int chmapif_sendall(unsigned char *buf, unsigned int len);
int chmapif_sendallwos(int sfd, unsigned char *buf, unsigned int len);
@ -66,9 +64,5 @@ void chmapif_on_disconnect(int id);
void do_final_chmapif(void);
#ifdef __cplusplus
}
#endif
#endif /* CHAR_MAPIF_H */

View File

@ -1,6 +1,12 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
#include "int_achievement.hpp"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "../common/db.h"
#include "../common/malloc.h"
#include "../common/mmo.h"
@ -9,14 +15,9 @@
#include "../common/sql.h"
#include "../common/strlib.h"
#include "char.h"
#include "inter.h"
#include "int_achievement.h"
#include "int_mail.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "char.hpp"
#include "inter.hpp"
#include "int_mail.hpp"
/**
* Load achievements for a character.

View File

@ -4,13 +4,8 @@
#ifndef _INT_ACHIEVEMENT_SQL_H_
#define _INT_ACHIEVEMENT_SQL_H_
#ifdef __cplusplus
extern "C" {
#endif
int inter_achievement_parse_frommap(int fd);
#ifdef __cplusplus
}
#endif
#endif /* _INT_ACHIEVEMENT_SQL_H_ */

View File

@ -1,6 +1,12 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
#include "int_auction.hpp"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "../common/mmo.h"
#include "../common/malloc.h"
#include "../common/showmsg.h"
@ -8,20 +14,19 @@
#include "../common/strlib.h"
#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"
#include <stdlib.h>
#include "char.hpp"
#include "char_mapif.hpp"
#include "inter.hpp"
#include "int_mail.hpp"
static DBMap* auction_db_ = NULL; // int auction_id -> struct auction_data*
void auction_delete(struct auction_data *auction);
static int auction_end_timer(int tid, unsigned int tick, int id, intptr_t data);
int auction_end_timer(int tid, unsigned int tick, int id, intptr_t data);
static int auction_count(uint32 char_id, bool buy)
int auction_count(uint32 char_id, bool buy)
{
int i = 0;
struct auction_data *auction;
@ -92,7 +97,7 @@ unsigned int auction_create(struct auction_data *auction)
StringBuf_Printf(&buf, ", `option_val%d`", j);
StringBuf_Printf(&buf, ", `option_parm%d`", j);
}
StringBuf_Printf(&buf, ") VALUES ('%d',?,'%d',?,'%d','%d','%d','%lu','%hu',?,'%d','%d','%d','%"PRIu64"'",
StringBuf_Printf(&buf, ") VALUES ('%d',?,'%d',?,'%d','%d','%d','%lu','%hu',?,'%d','%d','%d','%" PRIu64 "'",
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, auction->item.unique_id);
for( j = 0; j < MAX_SLOTS; j++ )
StringBuf_Printf(&buf, ",'%hu'", auction->item.card[j]);
@ -137,7 +142,7 @@ unsigned int auction_create(struct auction_data *auction)
return auction->auction_id;
}
static void mapif_Auction_message(uint32 char_id, unsigned char result)
void mapif_Auction_message(uint32 char_id, unsigned char result)
{
unsigned char buf[74];
@ -147,7 +152,7 @@ static void mapif_Auction_message(uint32 char_id, unsigned char result)
chmapif_sendall(buf,7);
}
static int auction_end_timer(int tid, unsigned int tick, int id, intptr_t data)
int auction_end_timer(int tid, unsigned int tick, int id, intptr_t data)
{
struct auction_data *auction;
if( (auction = (struct auction_data *)idb_get(auction_db_, id)) != NULL )
@ -263,7 +268,7 @@ void inter_auctions_fromsql(void)
Sql_FreeResult(sql_handle);
}
static void mapif_Auction_sendlist(int fd, uint32 char_id, short count, short pages, unsigned char *buf)
void mapif_Auction_sendlist(int fd, uint32 char_id, short count, short pages, unsigned char *buf)
{
int len = (sizeof(struct auction_data) * count) + 12;
@ -277,7 +282,7 @@ static void mapif_Auction_sendlist(int fd, uint32 char_id, short count, short pa
WFIFOSET(fd,len);
}
static void mapif_parse_Auction_requestlist(int fd)
void mapif_parse_Auction_requestlist(int fd)
{
char searchtext[NAME_LENGTH];
uint32 char_id = RFIFOL(fd,4), len = sizeof(struct auction_data);
@ -290,7 +295,7 @@ static void mapif_parse_Auction_requestlist(int fd)
memcpy(searchtext, RFIFOP(fd,16), NAME_LENGTH);
for( auction = dbi_first(iter); dbi_exists(iter); auction = dbi_next(iter) )
for( auction = static_cast<auction_data *>(dbi_first(iter)); dbi_exists(iter); auction = static_cast<auction_data *>(dbi_next(iter)) )
{
if( (type == 0 && auction->type != IT_ARMOR && auction->type != IT_PETARMOR) ||
(type == 1 && auction->type != IT_WEAPON) ||
@ -320,7 +325,7 @@ static void mapif_parse_Auction_requestlist(int fd)
mapif_Auction_sendlist(fd, char_id, j, pages, buf);
}
static void mapif_Auction_register(int fd, struct auction_data *auction)
void mapif_Auction_register(int fd, struct auction_data *auction)
{
int len = sizeof(struct auction_data) + 4;
@ -331,7 +336,7 @@ static void mapif_Auction_register(int fd, struct auction_data *auction)
WFIFOSET(fd,len);
}
static void mapif_parse_Auction_register(int fd)
void mapif_parse_Auction_register(int fd)
{
struct auction_data auction;
if( RFIFOW(fd,2) != sizeof(struct auction_data) + 4 )
@ -344,7 +349,7 @@ static void mapif_parse_Auction_register(int fd)
mapif_Auction_register(fd, &auction);
}
static void mapif_Auction_cancel(int fd, uint32 char_id, unsigned char result)
void mapif_Auction_cancel(int fd, uint32 char_id, unsigned char result)
{
WFIFOHEAD(fd,7);
WFIFOW(fd,0) = 0x3852;
@ -353,7 +358,7 @@ static void mapif_Auction_cancel(int fd, uint32 char_id, unsigned char result)
WFIFOSET(fd,7);
}
static void mapif_parse_Auction_cancel(int fd)
void mapif_parse_Auction_cancel(int fd)
{
uint32 char_id = RFIFOL(fd,2), auction_id = RFIFOL(fd,6);
struct auction_data *auction;
@ -382,7 +387,7 @@ static void mapif_parse_Auction_cancel(int fd)
mapif_Auction_cancel(fd, char_id, 0); // The auction has been canceled
}
static void mapif_Auction_close(int fd, uint32 char_id, unsigned char result)
void mapif_Auction_close(int fd, uint32 char_id, unsigned char result)
{
WFIFOHEAD(fd,7);
WFIFOW(fd,0) = 0x3853;
@ -391,7 +396,7 @@ static void mapif_Auction_close(int fd, uint32 char_id, unsigned char result)
WFIFOSET(fd,7);
}
static void mapif_parse_Auction_close(int fd)
void mapif_parse_Auction_close(int fd)
{
uint32 char_id = RFIFOL(fd,2), auction_id = RFIFOL(fd,6);
struct auction_data *auction;
@ -424,7 +429,7 @@ static void mapif_parse_Auction_close(int fd)
mapif_Auction_close(fd, char_id, 0); // You have ended the auction
}
static void mapif_Auction_bid(int fd, uint32 char_id, int bid, unsigned char result)
void mapif_Auction_bid(int fd, uint32 char_id, int bid, unsigned char result)
{
WFIFOHEAD(fd,11);
WFIFOW(fd,0) = 0x3855;
@ -434,7 +439,7 @@ static void mapif_Auction_bid(int fd, uint32 char_id, int bid, unsigned char res
WFIFOSET(fd,11);
}
static void mapif_parse_Auction_bid(int fd)
void mapif_parse_Auction_bid(int fd)
{
uint32 char_id = RFIFOL(fd,4), auction_id = RFIFOL(fd,8);
int bid = RFIFOL(fd,12);

View File

@ -4,17 +4,11 @@
#ifndef _INT_AUCTION_SQL_H_
#define _INT_AUCTION_SQL_H_
#ifdef __cplusplus
extern "C" {
#endif
int inter_auction_parse_frommap(int fd);
int inter_auction_sql_init(void);
void inter_auction_sql_final(void);
#ifdef __cplusplus
}
#endif
#endif /* _INT_AUCTION_SQL_H_ */

View File

@ -1,6 +1,11 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
#include "int_clan.hpp"
#include <stdlib.h>
#include <string.h> //memset
#include "../common/cbasetypes.h"
#include "../common/malloc.h"
#include "../common/mmo.h"
@ -8,11 +13,10 @@
#include "../common/socket.h"
#include "../common/strlib.h"
#include "char.h"
#include "char_mapif.h"
#include "inter.h"
#include "char.hpp"
#include "char_mapif.hpp"
#include "inter.hpp"
#include <stdlib.h>
//clan cache
static DBMap* clan_db; // int clan_id -> struct clan*

View File

@ -4,16 +4,8 @@
#ifndef _INT_CLAN_H_
#define _INT_CLAN_H_
#ifdef __cplusplus
extern "C" {
#endif
int inter_clan_parse_frommap( int fd );
int inter_clan_init(void);
void inter_clan_final(void);
#ifdef __cplusplus
}
#endif
#endif /* _INT_CLAN_H_ */

View File

@ -1,15 +1,20 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
#include "int_elemental.hpp"
#include <stdlib.h>
#include <string.h>
#include "../common/mmo.h"
#include "../common/strlib.h"
#include "../common/showmsg.h"
#include "../common/socket.h"
#include "../common/sql.h"
#include "char.h"
#include "inter.h"
#include <stdlib.h>
#include "char.hpp"
#include "inter.hpp"
bool mapif_elemental_save(struct s_elemental* ele) {
bool flag = true;
@ -58,7 +63,7 @@ bool mapif_elemental_load(int ele_id, uint32 char_id, struct s_elemental *ele) {
}
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, 1, &data, NULL); ele->mode = (e_mode)atoi(data);
Sql_GetData(sql_handle, 2, &data, NULL); ele->hp = atoi(data);
Sql_GetData(sql_handle, 3, &data, NULL); ele->sp = atoi(data);
Sql_GetData(sql_handle, 4, &data, NULL); ele->max_hp = atoi(data);
@ -88,7 +93,7 @@ bool mapif_elemental_delete(int ele_id) {
return true;
}
static void mapif_elemental_send(int fd, struct s_elemental *ele, unsigned char flag) {
void mapif_elemental_send(int fd, struct s_elemental *ele, unsigned char flag) {
int size = sizeof(struct s_elemental) + 5;
WFIFOHEAD(fd,size);
@ -99,37 +104,37 @@ static void mapif_elemental_send(int fd, struct s_elemental *ele, unsigned char
WFIFOSET(fd,size);
}
static void mapif_parse_elemental_create(int fd, struct s_elemental* ele) {
void mapif_parse_elemental_create(int fd, struct s_elemental* ele) {
bool result = mapif_elemental_save(ele);
mapif_elemental_send(fd, ele, result);
}
static void mapif_parse_elemental_load(int fd, int ele_id, uint32 char_id) {
void mapif_parse_elemental_load(int fd, int ele_id, uint32 char_id) {
struct s_elemental ele;
bool result = mapif_elemental_load(ele_id, char_id, &ele);
mapif_elemental_send(fd, &ele, result);
}
static void mapif_elemental_deleted(int fd, unsigned char flag) {
void mapif_elemental_deleted(int fd, unsigned char flag) {
WFIFOHEAD(fd,3);
WFIFOW(fd,0) = 0x387d;
WFIFOB(fd,2) = flag;
WFIFOSET(fd,3);
}
static void mapif_parse_elemental_delete(int fd, int ele_id) {
void mapif_parse_elemental_delete(int fd, int ele_id) {
bool result = mapif_elemental_delete(ele_id);
mapif_elemental_deleted(fd, result);
}
static void mapif_elemental_saved(int fd, unsigned char flag) {
void mapif_elemental_saved(int fd, unsigned char flag) {
WFIFOHEAD(fd,3);
WFIFOW(fd,0) = 0x387e;
WFIFOB(fd,2) = flag;
WFIFOSET(fd,3);
}
static void mapif_parse_elemental_save(int fd, struct s_elemental* ele) {
void mapif_parse_elemental_save(int fd, struct s_elemental* ele) {
bool result = mapif_elemental_save(ele);
mapif_elemental_saved(fd, result);
}

View File

@ -4,9 +4,6 @@
#ifndef _INT_ELEMENTAL_SQL_H_
#define _INT_ELEMENTAL_SQL_H_
#ifdef __cplusplus
extern "C" {
#endif
struct s_elemental;
@ -16,8 +13,5 @@ int inter_elemental_parse_frommap(int fd);
bool mapif_elemental_delete(int ele_id);
#ifdef __cplusplus
}
#endif
#endif /* _INT_ELEMENTAL_SQL_H_ */

View File

@ -1,6 +1,12 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
#include "int_guild.hpp"
#include <stdlib.h>
#define __STDC_WANT_LIB_EXT1__ 1
#include <string.h>
#include "../common/cbasetypes.h"
#include "../common/mmo.h"
#include "../common/malloc.h"
@ -8,12 +14,11 @@
#include "../common/showmsg.h"
#include "../common/strlib.h"
#include "../common/timer.h"
#include "char.h"
#include "char_mapif.h"
#include "inter.h"
#include "int_guild.h"
#include <stdlib.h>
#include "char.hpp"
#include "char_mapif.hpp"
#include "inter.hpp"
#define GS_MEMBER_UNMODIFIED 0x00
#define GS_MEMBER_MODIFIED 0x01
@ -36,14 +41,14 @@ static unsigned int guild_exp[100];
int mapif_parse_GuildLeave(int fd,int guild_id,uint32 account_id,uint32 char_id,int flag,const char *mes);
int mapif_guild_broken(int guild_id,int flag);
static bool guild_check_empty(struct guild *g);
bool guild_check_empty(struct guild *g);
int guild_calcinfo(struct guild *g);
int mapif_guild_basicinfochanged(int guild_id,int type,const void *data,int len);
int mapif_guild_info(int fd,struct guild *g);
int guild_break_sub(int key,void *data,va_list ap);
int inter_guild_tosql(struct guild *g,int flag);
static int guild_save_timer(int tid, unsigned int tick, int id, intptr_t data)
int guild_save_timer(int tid, unsigned int tick, int id, intptr_t data)
{
static int last_id = 0; //To know in which guild we were.
int state = 0; //0: Have not reached last guild. 1: Reached last guild, ready for save. 2: Some guild saved, don't do further saving.
@ -217,7 +222,7 @@ int inter_guild_tosql(struct guild *g,int flag)
StringBuf_AppendStr(&buf, ", ");
//else //last condition using add_coma setting
// add_comma = true;
StringBuf_Printf(&buf, "`guild_lv`=%d, `skill_point`=%d, `exp`=%"PRIu64", `next_exp`=%u, `max_member`=%d", g->guild_lv, g->skill_point, g->exp, g->next_exp, g->max_member);
StringBuf_Printf(&buf, "`guild_lv`=%d, `skill_point`=%d, `exp`=%" PRIu64 ", `next_exp`=%u, `max_member`=%d", g->guild_lv, g->skill_point, g->exp, g->next_exp, g->max_member);
}
StringBuf_Printf(&buf, " WHERE `guild_id`=%d", g->guild_id);
if( SQL_ERROR == Sql_Query(sql_handle, "%s", StringBuf_Value(&buf)) )
@ -237,7 +242,7 @@ int inter_guild_tosql(struct guild *g,int flag)
//Since nothing references guild member table as foreign keys, it's safe to use REPLACE INTO
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')",
"VALUES ('%d','%d','%d','%d','%d','%d','%d','%d','%" PRIu64 "','%d','%d','%d','%s')",
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) )
@ -546,7 +551,7 @@ int inter_guildcastle_tosql(struct guild_castle *gc)
}
// Read guild_castle from SQL
static struct guild_castle* inter_guildcastle_fromsql(int castle_id)
struct guild_castle* inter_guildcastle_fromsql(int castle_id)
{
char *data;
int i;
@ -598,7 +603,7 @@ static struct guild_castle* inter_guildcastle_fromsql(int castle_id)
// Read exp_guild.txt
static bool exp_guild_parse_row(char* split[], int column, int current)
bool exp_guild_parse_row(char* split[], int column, int current)
{
unsigned int exp = (unsigned int)atol(split[0]);
@ -739,7 +744,7 @@ int inter_guild_sql_init(void)
/**
* @see DBApply
*/
static int guild_db_final(DBKey key, DBData *data, va_list ap)
int guild_db_final(DBKey key, DBData *data, va_list ap)
{
struct guild *g = (struct guild*)db_data2ptr(data);
if (g->save_flag&GS_MASK) {
@ -786,7 +791,7 @@ int search_guildname(char *str)
}
// Check if guild is empty
static bool guild_check_empty(struct guild *g)
bool guild_check_empty(struct guild *g)
{
int i;
ARR_FIND( 0, g->max_member, i, g->member[i].account_id > 0 );
@ -1647,7 +1652,7 @@ int mapif_parse_GuildSkillUp(int fd,int guild_id,uint16 skill_id,uint32 account_
}
//Manual deletion of an alliance when partnering guild does not exists. [Skotlex]
static int mapif_parse_GuildDeleteAlliance(struct guild *g, int guild_id, uint32 account_id1, uint32 account_id2, int flag)
int mapif_parse_GuildDeleteAlliance(struct guild *g, int guild_id, uint32 account_id1, uint32 account_id2, int flag)
{
int i;
char name[NAME_LENGTH];

View File

@ -4,13 +4,9 @@
#ifndef _INT_GUILD_SQL_H_
#define _INT_GUILD_SQL_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "../common/cbasetypes.h"
enum {
enum e_guild_action : uint32 {
GS_BASIC = 0x0001,
GS_MEMBER = 0x0002,
GS_POSITION = 0x0004,
@ -40,8 +36,4 @@ int inter_guild_charname_changed(int guild_id,uint32 account_id, uint32 char_id,
int inter_guild_CharOnline(uint32 char_id, int guild_id);
int inter_guild_CharOffline(uint32 char_id, int guild_id);
#ifdef __cplusplus
}
#endif
#endif /* _INT_GUILD_SQL_H_ */

View File

@ -1,16 +1,20 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
#include "int_homun.hpp"
#include <stdlib.h>
#include <string.h>
#include "../common/mmo.h"
#include "../common/strlib.h"
#include "../common/showmsg.h"
#include "../common/socket.h"
#include "../common/utils.h"
#include "../common/sql.h"
#include "char.h"
#include "inter.h"
#include <stdlib.h>
#include "char.hpp"
#include "inter.hpp"
int inter_homunculus_sql_init(void)
@ -22,7 +26,7 @@ void inter_homunculus_sql_final(void)
return;
}
static void mapif_homunculus_created(int fd, uint32 account_id, struct s_homunculus *sh, unsigned char flag)
void mapif_homunculus_created(int fd, uint32 account_id, struct s_homunculus *sh, unsigned char flag)
{
WFIFOHEAD(fd, sizeof(struct s_homunculus)+9);
WFIFOW(fd,0) = 0x3890;
@ -33,7 +37,7 @@ static void mapif_homunculus_created(int fd, uint32 account_id, struct s_homuncu
WFIFOSET(fd, WFIFOW(fd,2));
}
static void mapif_homunculus_deleted(int fd, int flag)
void mapif_homunculus_deleted(int fd, int flag)
{
WFIFOHEAD(fd, 3);
WFIFOW(fd, 0) = 0x3893;
@ -41,7 +45,7 @@ static void mapif_homunculus_deleted(int fd, int flag)
WFIFOSET(fd, 3);
}
static void mapif_homunculus_loaded(int fd, uint32 account_id, struct s_homunculus *hd)
void mapif_homunculus_loaded(int fd, uint32 account_id, struct s_homunculus *hd)
{
WFIFOHEAD(fd, sizeof(struct s_homunculus)+9);
WFIFOW(fd,0) = 0x3891;
@ -60,7 +64,7 @@ static void mapif_homunculus_loaded(int fd, uint32 account_id, struct s_homuncul
WFIFOSET(fd, sizeof(struct s_homunculus)+9);
}
static void mapif_homunculus_saved(int fd, uint32 account_id, bool flag)
void mapif_homunculus_saved(int fd, uint32 account_id, bool flag)
{
WFIFOHEAD(fd, 7);
WFIFOW(fd,0) = 0x3892;
@ -69,7 +73,7 @@ static void mapif_homunculus_saved(int fd, uint32 account_id, bool flag)
WFIFOSET(fd, 7);
}
static void mapif_homunculus_renamed(int fd, uint32 account_id, uint32 char_id, unsigned char flag, char* name)
void mapif_homunculus_renamed(int fd, uint32 account_id, uint32 char_id, unsigned char flag, char* name)
{
WFIFOHEAD(fd, NAME_LENGTH+12);
WFIFOW(fd, 0) = 0x3894;
@ -261,32 +265,32 @@ bool mapif_homunculus_rename(char *name)
}
static void mapif_parse_homunculus_create(int fd, int len, uint32 account_id, struct s_homunculus* phd)
void mapif_parse_homunculus_create(int fd, int len, uint32 account_id, struct s_homunculus* phd)
{
bool result = mapif_homunculus_save(phd);
mapif_homunculus_created(fd, account_id, phd, result);
}
static void mapif_parse_homunculus_delete(int fd, int homun_id)
void mapif_parse_homunculus_delete(int fd, int homun_id)
{
bool result = mapif_homunculus_delete(homun_id);
mapif_homunculus_deleted(fd, result);
}
static void mapif_parse_homunculus_load(int fd, uint32 account_id, int homun_id)
void mapif_parse_homunculus_load(int fd, uint32 account_id, int homun_id)
{
struct s_homunculus hd;
bool result = mapif_homunculus_load(homun_id, &hd);
mapif_homunculus_loaded(fd, account_id, ( result ? &hd : NULL ));
}
static void mapif_parse_homunculus_save(int fd, int len, uint32 account_id, struct s_homunculus* phd)
void mapif_parse_homunculus_save(int fd, int len, uint32 account_id, struct s_homunculus* phd)
{
bool result = mapif_homunculus_save(phd);
mapif_homunculus_saved(fd, account_id, result);
}
static void mapif_parse_homunculus_rename(int fd, uint32 account_id, uint32 char_id, char* name)
void mapif_parse_homunculus_rename(int fd, uint32 account_id, uint32 char_id, char* name)
{
bool result = mapif_homunculus_rename(name);
mapif_homunculus_renamed(fd, account_id, char_id, result, name);

View File

@ -4,10 +4,7 @@
#ifndef _INT_HOMUN_SQL_H_
#define _INT_HOMUN_SQL_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "../common/cbasetypes.h"
struct s_homunculus;
int inter_homunculus_sql_init(void);
@ -19,8 +16,5 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd);
bool mapif_homunculus_delete(int homun_id);
bool mapif_homunculus_rename(char *name);
#ifdef __cplusplus
}
#endif
#endif /* _INT_HOMUN_SQL_H_ */

View File

@ -1,22 +1,26 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
#include "int_mail.hpp"
#include <stdlib.h>
#include <string.h>
#include "../common/mmo.h"
#include "../common/showmsg.h"
#include "../common/socket.h"
#include "../common/strlib.h"
#include "../common/sql.h"
#include "char.h"
#include "char_mapif.h"
#include "inter.h"
#include <stdlib.h>
#include "char.hpp"
#include "char_mapif.hpp"
#include "inter.hpp"
static bool mail_loadmessage(int mail_id, struct mail_message* msg);
static void mapif_Mail_return(int fd, uint32 char_id, int mail_id);
static void mapif_Mail_delete(int fd, uint32 char_id, int mail_id, bool deleted);
bool mail_loadmessage(int mail_id, struct mail_message* msg);
void mapif_Mail_return(int fd, uint32 char_id, int mail_id);
void mapif_Mail_delete(int fd, uint32 char_id, int mail_id, bool deleted);
static int mail_fromsql(uint32 char_id, struct mail_data* md)
int mail_fromsql(uint32 char_id, struct mail_data* md)
{
int i;
char *data;
@ -123,7 +127,7 @@ int mail_savemessage(struct mail_message* msg)
found = true;
}
StringBuf_Printf(&buf, "('%"PRIu64"', '%hu', '%d', '%hu', '%d', '%d', '%d', '%"PRIu64"', '%d'", (uint64)msg->id, i, msg->item[i].amount, msg->item[i].nameid, msg->item[i].refine, msg->item[i].attribute, msg->item[i].identify, msg->item[i].unique_id, msg->item[i].bound);
StringBuf_Printf(&buf, "('%" PRIu64 "', '%hu', '%d', '%hu', '%d', '%d', '%d', '%" PRIu64 "', '%d'", (uint64)msg->id, i, msg->item[i].amount, msg->item[i].nameid, msg->item[i].refine, msg->item[i].attribute, msg->item[i].identify, msg->item[i].unique_id, msg->item[i].bound);
for (j = 0; j < MAX_SLOTS; j++)
StringBuf_Printf(&buf, ", '%hu'", msg->item[i].card[j]);
for (j = 0; j < MAX_ITEM_RDM_OPT; ++j) {
@ -145,7 +149,7 @@ int mail_savemessage(struct mail_message* msg)
/// Retrieves a single message from the database.
/// Returns true if the operation succeeds (or false if it fails).
static bool mail_loadmessage(int mail_id, struct mail_message* msg)
bool mail_loadmessage(int mail_id, struct mail_message* msg)
{
int i, j;
StringBuf buf;
@ -167,7 +171,7 @@ static bool mail_loadmessage(int mail_id, struct mail_message* msg)
Sql_GetData(sql_handle, 7, &data, NULL); msg->timestamp = atoi(data);
Sql_GetData(sql_handle, 8, &data, NULL); msg->status = (mail_status)atoi(data);
Sql_GetData(sql_handle, 9, &data, NULL); msg->zeny = atoi(data);
Sql_GetData(sql_handle,10, &data, NULL); msg->type = atoi(data);
Sql_GetData(sql_handle,10, &data, NULL); msg->type = (mail_inbox_type)atoi(data);
if( msg->type == MAIL_INBOX_NORMAL && charserv_config.mail_return_days > 0 ){
msg->scheduled_deletion = msg->timestamp + charserv_config.mail_return_days * 24 * 60 * 60;
@ -230,7 +234,7 @@ static bool mail_loadmessage(int mail_id, struct mail_message* msg)
return true;
}
static int mail_timer_sub( int limit, enum mail_inbox_type type ){
int mail_timer_sub( int limit, enum mail_inbox_type type ){
struct{
int mail_id;
int char_id;
@ -300,7 +304,7 @@ int mail_delete_timer( int tid, unsigned int tick, int id, intptr_t data ){
/*==========================================
* Client Inbox Request
*------------------------------------------*/
static void mapif_Mail_sendinbox(int fd, uint32 char_id, unsigned char flag, enum mail_inbox_type type)
void mapif_Mail_sendinbox(int fd, uint32 char_id, unsigned char flag, enum mail_inbox_type type)
{
struct mail_data md;
mail_fromsql(char_id, &md);
@ -316,15 +320,15 @@ static void mapif_Mail_sendinbox(int fd, uint32 char_id, unsigned char flag, enu
WFIFOSET(fd,WFIFOW(fd,2));
}
static void mapif_parse_Mail_requestinbox(int fd)
void mapif_parse_Mail_requestinbox(int fd)
{
mapif_Mail_sendinbox(fd, RFIFOL(fd,2), RFIFOB(fd,6), RFIFOB(fd,7));
mapif_Mail_sendinbox(fd, RFIFOL(fd,2), RFIFOB(fd,6), (mail_inbox_type)RFIFOB(fd,7));
}
/*==========================================
* Mark mail as 'Read'
*------------------------------------------*/
static void mapif_parse_Mail_read(int fd)
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'", schema_config.mail_db, MAIL_READ, mail_id) )
@ -334,7 +338,7 @@ static void mapif_parse_Mail_read(int fd)
/*==========================================
* Client Attachment Request
*------------------------------------------*/
static bool mail_DeleteAttach(int mail_id){
bool mail_DeleteAttach(int mail_id){
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `id` = '%d'", schema_config.mail_attachment_db, mail_id ) ){
Sql_ShowDebug(sql_handle);
return false;
@ -343,7 +347,7 @@ static bool mail_DeleteAttach(int mail_id){
return true;
}
static void mapif_Mail_getattach(int fd, uint32 char_id, int mail_id, int type)
void mapif_Mail_getattach(int fd, uint32 char_id, int mail_id, int type)
{
struct mail_message msg;
@ -407,7 +411,7 @@ static void mapif_Mail_getattach(int fd, uint32 char_id, int mail_id, int type)
WFIFOSET(fd,WFIFOW(fd,2));
}
static void mapif_parse_Mail_getattach(int fd)
void mapif_parse_Mail_getattach(int fd)
{
mapif_Mail_getattach(fd, RFIFOL(fd,2), RFIFOL(fd,6),RFIFOB(fd,10));
}
@ -415,7 +419,7 @@ static void mapif_parse_Mail_getattach(int fd)
/*==========================================
* Delete Mail
*------------------------------------------*/
static void mapif_Mail_delete(int fd, uint32 char_id, int mail_id, bool deleted)
void mapif_Mail_delete(int fd, uint32 char_id, int mail_id, bool deleted)
{
bool failed = false;
@ -441,7 +445,7 @@ static void mapif_Mail_delete(int fd, uint32 char_id, int mail_id, bool deleted)
WFIFOSET(fd,11);
}
static void mapif_parse_Mail_delete(int fd)
void mapif_parse_Mail_delete(int fd)
{
mapif_Mail_delete(fd, RFIFOL(fd,2), RFIFOL(fd,6), false);
}
@ -468,7 +472,7 @@ void mapif_Mail_new(struct mail_message *msg)
/*==========================================
* Return Mail
*------------------------------------------*/
static void mapif_Mail_return(int fd, uint32 char_id, int mail_id)
void mapif_Mail_return(int fd, uint32 char_id, int mail_id)
{
struct mail_message msg;
int new_mail = 0;
@ -516,7 +520,7 @@ static void mapif_Mail_return(int fd, uint32 char_id, int mail_id)
WFIFOSET(fd,11);
}
static void mapif_parse_Mail_return(int fd)
void mapif_parse_Mail_return(int fd)
{
mapif_Mail_return(fd, RFIFOL(fd,2), RFIFOL(fd,6));
}
@ -524,7 +528,7 @@ static void mapif_parse_Mail_return(int fd)
/*==========================================
* Send Mail
*------------------------------------------*/
static void mapif_Mail_send(int fd, struct mail_message* msg)
void mapif_Mail_send(int fd, struct mail_message* msg)
{
int len = sizeof(struct mail_message) + 4;
@ -535,7 +539,7 @@ static void mapif_Mail_send(int fd, struct mail_message* msg)
WFIFOSET(fd,len);
}
static void mapif_parse_Mail_send(int fd)
void mapif_parse_Mail_send(int fd)
{
struct mail_message msg;
char esc_name[NAME_LENGTH*2+1];
@ -609,7 +613,7 @@ bool mail_sendmail(int send_id, const char* send_name, int dest_id, const char*
return true;
}
static void mapif_Mail_receiver_send( int fd, int requesting_char_id, int char_id, int class_, int base_level, const char* name ){
void mapif_Mail_receiver_send( int fd, int requesting_char_id, int char_id, int class_, int base_level, const char* name ){
WFIFOHEAD(fd,38);
WFIFOW(fd,0) = 0x384e;
WFIFOL(fd,2) = requesting_char_id;
@ -620,7 +624,7 @@ static void mapif_Mail_receiver_send( int fd, int requesting_char_id, int char_i
WFIFOSET(fd,38);
}
static void mapif_parse_Mail_receiver_check( int fd ){
void mapif_parse_Mail_receiver_check( int fd ){
char name[NAME_LENGTH], esc_name[NAME_LENGTH * 2 + 1];
uint32 char_id = 0;
uint16 class_ = 0, base_level = 0;

View File

@ -4,9 +4,9 @@
#ifndef _INT_MAIL_SQL_H_
#define _INT_MAIL_SQL_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "../common/cbasetypes.h"
struct mail_message;
int mail_return_timer( int tid, unsigned int tick, int id, intptr_t data );
int mail_delete_timer( int tid, unsigned int tick, int id, intptr_t data );
@ -20,8 +20,6 @@ void inter_mail_sql_final(void);
int mail_savemessage(struct mail_message* msg);
void mapif_Mail_new(struct mail_message *msg);
#ifdef __cplusplus
}
#endif
#endif /* _INT_MAIL_SQL_H_ */

View File

@ -1,15 +1,19 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
#include "int_mercenary.hpp"
#include <stdlib.h>
#include <string.h>
#include "../common/mmo.h"
#include "../common/strlib.h"
#include "../common/showmsg.h"
#include "../common/socket.h"
#include "../common/sql.h"
#include "char.h"
#include "inter.h"
#include <stdlib.h>
#include "char.hpp"
#include "inter.hpp"
bool mercenary_owner_fromsql(uint32 char_id, struct mmo_charstatus *status)
{
@ -132,7 +136,7 @@ bool mapif_mercenary_delete(int merc_id)
return true;
}
static void mapif_mercenary_send(int fd, struct s_mercenary *merc, unsigned char flag)
void mapif_mercenary_send(int fd, struct s_mercenary *merc, unsigned char flag)
{
int size = sizeof(struct s_mercenary) + 5;
@ -144,20 +148,20 @@ static void mapif_mercenary_send(int fd, struct s_mercenary *merc, unsigned char
WFIFOSET(fd,size);
}
static void mapif_parse_mercenary_create(int fd, struct s_mercenary* merc)
void mapif_parse_mercenary_create(int fd, struct s_mercenary* merc)
{
bool result = mapif_mercenary_save(merc);
mapif_mercenary_send(fd, merc, result);
}
static void mapif_parse_mercenary_load(int fd, int merc_id, uint32 char_id)
void mapif_parse_mercenary_load(int fd, int merc_id, uint32 char_id)
{
struct s_mercenary merc;
bool result = mapif_mercenary_load(merc_id, char_id, &merc);
mapif_mercenary_send(fd, &merc, result);
}
static void mapif_mercenary_deleted(int fd, unsigned char flag)
void mapif_mercenary_deleted(int fd, unsigned char flag)
{
WFIFOHEAD(fd,3);
WFIFOW(fd,0) = 0x3871;
@ -165,13 +169,13 @@ static void mapif_mercenary_deleted(int fd, unsigned char flag)
WFIFOSET(fd,3);
}
static void mapif_parse_mercenary_delete(int fd, int merc_id)
void mapif_parse_mercenary_delete(int fd, int merc_id)
{
bool result = mapif_mercenary_delete(merc_id);
mapif_mercenary_deleted(fd, result);
}
static void mapif_mercenary_saved(int fd, unsigned char flag)
void mapif_mercenary_saved(int fd, unsigned char flag)
{
WFIFOHEAD(fd,3);
WFIFOW(fd,0) = 0x3872;
@ -179,7 +183,7 @@ static void mapif_mercenary_saved(int fd, unsigned char flag)
WFIFOSET(fd,3);
}
static void mapif_parse_mercenary_save(int fd, struct s_mercenary* merc)
void mapif_parse_mercenary_save(int fd, struct s_mercenary* merc)
{
bool result = mapif_mercenary_save(merc);
mapif_mercenary_saved(fd, result);

View File

@ -4,11 +4,9 @@
#ifndef _INT_MERCENARY_SQL_H_
#define _INT_MERCENARY_SQL_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "../common/cbasetypes.h"
struct s_mercenary;
// struct s_mercenary;
int inter_mercenary_sql_init(void);
void inter_mercenary_sql_final(void);
@ -21,8 +19,5 @@ bool mercenary_owner_delete(uint32 char_id);
bool mapif_mercenary_delete(int merc_id);
#ifdef __cplusplus
}
#endif
#endif /* _INT_MERCENARY_SQL_H_ */

View File

@ -1,6 +1,11 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
#include "int_party.hpp"
#include <stdlib.h>
#include <string.h>
#include "../common/cbasetypes.h"
#include "../common/mmo.h"
#include "../common/malloc.h"
@ -9,12 +14,11 @@
#include "../common/showmsg.h"
#include "../common/mapindex.h"
#include "../common/sql.h"
#include "char.h"
#include "char_mapif.h"
#include "inter.h"
#include "int_party.h"
#include <stdlib.h>
#include "char.hpp"
#include "char_mapif.hpp"
#include "inter.hpp"
struct party_data {
struct party party;
@ -59,7 +63,7 @@ static int int_party_check_lv(struct party_data *p) {
return 1;
}
//Calculates the state of a party.
static void int_party_calc_state(struct party_data *p)
void int_party_calc_state(struct party_data *p)
{
int i;
p->min_lv = UINT_MAX;
@ -382,7 +386,7 @@ int mapif_party_created(int fd,uint32 account_id,uint32 char_id,struct party *p)
}
//Party information not found
static void mapif_party_noinfo(int fd, int party_id, uint32 char_id)
void mapif_party_noinfo(int fd, int party_id, uint32 char_id)
{
WFIFOHEAD(fd, 12);
WFIFOW(fd,0) = 0x3821;
@ -394,7 +398,7 @@ static void mapif_party_noinfo(int fd, int party_id, uint32 char_id)
}
//Digest party information
static void mapif_party_info(int fd, struct party* p, uint32 char_id)
void mapif_party_info(int fd, struct party* p, uint32 char_id)
{
unsigned char buf[8 + sizeof(struct party)];
WBUFW(buf,0) = 0x3821;
@ -552,7 +556,7 @@ int mapif_parse_CreateParty(int fd, char *name, int item, int item2, struct part
}
// Party information request
static void mapif_parse_PartyInfo(int fd, int party_id, uint32 char_id)
void mapif_parse_PartyInfo(int fd, int party_id, uint32 char_id)
{
struct party_data *p;
p = inter_party_fromsql(party_id);

View File

@ -4,12 +4,10 @@
#ifndef _INT_PARTY_SQL_H_
#define _INT_PARTY_SQL_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "../common/cbasetypes.h"
//Party Flags on what to save/delete.
enum {
enum e_PartySaveWhatFlag {
PS_CREATE = 0x01, //Create a new party entry (index holds leader's info)
PS_BASIC = 0x02, //Update basic party info.
PS_LEADER = 0x04, //Update party's leader
@ -18,7 +16,7 @@ enum {
PS_BREAK = 0x20, //Specify that this party must be deleted.
};
struct party;
//struct party;
int inter_party_parse_frommap(int fd);
int inter_party_sql_init(void);
@ -28,8 +26,4 @@ int inter_party_charname_changed(int party_id, uint32 char_id, char *name);
int inter_party_CharOnline(uint32 char_id, int party_id);
int inter_party_CharOffline(uint32 char_id, int party_id);
#ifdef __cplusplus
}
#endif
#endif /* _INT_PARTY_SQL_H_ */

View File

@ -1,6 +1,11 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
#include "int_pet.hpp"
#include <stdlib.h>
#include <string.h>
#include "../common/mmo.h"
#include "../common/malloc.h"
#include "../common/socket.h"
@ -8,10 +13,10 @@
#include "../common/showmsg.h"
#include "../common/utils.h"
#include "../common/sql.h"
#include "char.h"
#include "inter.h"
#include <stdlib.h>
#include "char.hpp"
#include "inter.hpp"
struct s_pet *pet_pt;

View File

@ -4,23 +4,21 @@
#ifndef _INT_PET_SQL_H_
#define _INT_PET_SQL_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "../common/cbasetypes.h"
struct s_pet;
int inter_pet_init(void);
void inter_pet_sql_final(void);
int inter_pet_save(void);
int inter_pet_delete(int pet_id);
int inter_pet_parse_frommap(int fd);
int inter_pet_sql_init(void);
//extern char pet_txt[256];
//extern char pet_txt[256];
int inter_pet_tosql(int pet_id, struct s_pet *p);
#ifdef __cplusplus
}
#endif
#endif /* _INT_PET_SQL_H_ */

View File

@ -1,17 +1,19 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
#include "int_quest.hpp"
#include <stdlib.h>
#include <string.h>
#include "../common/mmo.h"
#include "../common/malloc.h"
#include "../common/socket.h"
#include "../common/strlib.h"
#include "../common/sql.h"
#include "char.h"
#include "inter.h"
#include "int_quest.h"
#include <stdlib.h>
#include "char.hpp"
#include "inter.hpp"
/**
* Loads the entire questlog for a character.

View File

@ -4,15 +4,11 @@
#ifndef _QUEST_H_
#define _QUEST_H_
#ifdef __cplusplus
extern "C" {
#endif
int inter_quest_parse_frommap(int fd);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,9 +1,14 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
#pragma warning(disable:4800)
#pragma warning(disable:4800) //forcing value to bool
#include "int_storage.hpp"
#include <stdlib.h>
#include <string.h>
//#include <string>
#include "int_storage.h"
#include "../common/malloc.h"
#include "../common/mmo.h"
@ -11,10 +16,8 @@
#include "../common/socket.h"
#include "../common/strlib.h" // StringBuf
#include "../common/sql.h"
#include "char.h"
#include "inter.h"
#include <stdlib.h>
#include "char.hpp"
#include "inter.hpp"
/**
* Check if storage ID is valid
@ -64,7 +67,7 @@ const char *inter_premiumStorage_getPrintableName(uint8 id) {
* @param p: Inventory entries
* @return 0 if success, or error count
*/
static int inventory_tosql(uint32 char_id, struct s_storage* p)
int inventory_tosql(uint32 char_id, struct s_storage* p)
{
return char_memitemdata_to_sql(p->u.items_inventory, MAX_INVENTORY, char_id, TABLE_INVENTORY, p->stor_id);
}
@ -75,7 +78,7 @@ static int inventory_tosql(uint32 char_id, struct s_storage* p)
* @param p: Storage entries
* @return 0 if success, or error count
*/
static int storage_tosql(uint32 account_id, struct s_storage* p)
int storage_tosql(uint32 account_id, struct s_storage* p)
{
return char_memitemdata_to_sql(p->u.items_storage, MAX_STORAGE, account_id, TABLE_STORAGE, p->stor_id);
}
@ -86,7 +89,7 @@ static int storage_tosql(uint32 account_id, struct s_storage* p)
* @param p: Cart entries
* @return 0 if success, or error count
*/
static int cart_tosql(uint32 char_id, struct s_storage* p)
int cart_tosql(uint32 char_id, struct s_storage* p)
{
return char_memitemdata_to_sql(p->u.items_cart, MAX_CART, char_id, TABLE_CART, p->stor_id);
}
@ -97,7 +100,7 @@ static int cart_tosql(uint32 char_id, struct s_storage* p)
* @param p: Inventory list to save the entries
* @return True if success, False if failed
*/
static bool inventory_fromsql(uint32 char_id, struct s_storage* p)
bool inventory_fromsql(uint32 char_id, struct s_storage* p)
{
return char_memitemdata_from_sql( p, MAX_INVENTORY, char_id, TABLE_INVENTORY, p->stor_id );
}
@ -108,7 +111,7 @@ static bool inventory_fromsql(uint32 char_id, struct s_storage* p)
* @param p: Cart list to save the entries
* @return True if success, False if failed
*/
static bool cart_fromsql(uint32 char_id, struct s_storage* p)
bool cart_fromsql(uint32 char_id, struct s_storage* p)
{
return char_memitemdata_from_sql( p, MAX_CART, char_id, TABLE_CART, p->stor_id );
}
@ -120,7 +123,7 @@ static bool cart_fromsql(uint32 char_id, struct s_storage* p)
* @param stor_id: Storage ID
* @return True if success, False if failed
*/
static bool storage_fromsql(uint32 account_id, struct s_storage* p)
bool storage_fromsql(uint32 account_id, struct s_storage* p)
{
return char_memitemdata_from_sql( p, MAX_STORAGE, account_id, TABLE_STORAGE, p->stor_id );
}
@ -148,7 +151,7 @@ bool guild_storage_fromsql(int guild_id, struct s_storage* p)
return char_memitemdata_from_sql( p, MAX_GUILD_STORAGE, guild_id, TABLE_GUILD_STORAGE, p->stor_id );
}
static void inter_storage_checkDB(void) {
void inter_storage_checkDB(void) {
// Checking storage tables
for (auto storage_table : interserv_config.storages) {
if (SQL_ERROR == Sql_Query(sql_handle, "SELECT `id`,`account_id`,`nameid`,`amount`,`equip`,`identify`,`refine`,"
@ -261,7 +264,7 @@ bool mapif_parse_SaveGuildStorage(int fd)
* IZ 0x3856 <account_id>.L <guild_id>.W
* Tells map-server if the process if complete, unlock the guild storage
*/
static void mapif_itembound_ack(int fd, int account_id, int guild_id)
void mapif_itembound_ack(int fd, int account_id, int guild_id)
{
WFIFOHEAD(fd,8);
WFIFOW(fd,0) = 0x3856;
@ -283,7 +286,7 @@ static void mapif_itembound_ack(int fd, int account_id, int guild_id)
* @param count
* @author [Cydh]
*/
static void mapif_itembound_store2gstorage(int fd, int guild_id, struct item items[], unsigned short count) {
void mapif_itembound_store2gstorage(int fd, int guild_id, struct item items[], unsigned short count) {
int size = 8 + sizeof(struct item) * MAX_INVENTORY, i;
WFIFOHEAD(fd, size);
@ -450,7 +453,7 @@ bool mapif_parse_itembound_retrieve(int fd)
* @param entries Inventory/cart/storage entries
* @param result
*/
static void mapif_storage_data_loaded(int fd, uint32 account_id, char type, struct s_storage entries, bool result) {
void mapif_storage_data_loaded(int fd, uint32 account_id, char type, struct s_storage entries, bool result) {
uint16 size = sizeof(struct s_storage) + 10;
WFIFOHEAD(fd, size);

View File

@ -6,9 +6,6 @@
#include "../common/cbasetypes.h"
#ifdef __cplusplus
extern "C" {
#endif
struct s_storage;
@ -24,8 +21,5 @@ bool inter_storage_parse_frommap(int fd);
bool guild_storage_tosql(int guild_id, struct s_storage *p);
#ifdef __cplusplus
}
#endif
#endif /* _INT_STORAGE_SQL_H_ */

View File

@ -1,37 +1,41 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
#include "../common/mmo.h"
#include "../common/cbasetypes.h"
#include "../common/malloc.h"
#include "../common/strlib.h"
#include "../common/showmsg.h"
#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"
#include "int_storage.h"
#include "int_pet.h"
#include "int_homun.h"
#include "int_mercenary.h"
#include "int_mail.h"
#include "int_auction.h"
#include "int_quest.h"
#include "int_elemental.h"
#include "int_clan.h"
#include "int_achievement.h"
#include "inter.hpp"
#include <string.h>
#include <stdlib.h>
#include <sys/stat.h> // for stat/lstat/fstat - [Dekamaster/Ultimate GM Tool]
#include <yaml-cpp/yaml.h>
#include <string>
#include <vector>
#include <stdlib.h>
#include <sys/stat.h> // for stat/lstat/fstat - [Dekamaster/Ultimate GM Tool]
#include "../common/cbasetypes.h"
#include "../common/malloc.h"
#include "../common/strlib.h"
#include "../common/showmsg.h"
#include "../common/socket.h"
#include "../common/timer.h"
#include "char.hpp"
#include "char_logif.hpp"
#include "char_mapif.hpp"
#include "inter.hpp"
#include "int_party.hpp"
#include "int_guild.hpp"
#include "int_storage.hpp"
#include "int_pet.hpp"
#include "int_homun.hpp"
#include "int_mercenary.hpp"
#include "int_mail.hpp"
#include "int_auction.hpp"
#include "int_quest.hpp"
#include "int_elemental.hpp"
#include "int_clan.hpp"
#include "int_achievement.hpp"
#define WISDATA_TTL (60*1000) //Wis data Time To Live (60 seconds)
@ -412,7 +416,7 @@ void inter_to_fd(int fd, int u_fd, int aid, char* msg, ...) {
* @param acc_id : id of player found
* @param acc_name : name of player found
*/
static void mapif_acc_info_ack(int fd, int u_fd, int acc_id, const char* acc_name){
void mapif_acc_info_ack(int fd, int u_fd, int acc_id, const char* acc_name){
WFIFOHEAD(fd,10 + NAME_LENGTH);
WFIFOW(fd,0) = 0x3808;
WFIFOL(fd,2) = u_fd;
@ -772,7 +776,7 @@ int inter_accreg_fromsql(uint32 account_id, uint32 char_id, int fd, int type)
/*==========================================
* read config file
*------------------------------------------*/
static int inter_config_read(const char* cfgName)
int inter_config_read(const char* cfgName)
{
char line[1024];
FILE* fp;
@ -838,7 +842,7 @@ int inter_log(char* fmt, ...)
return 0;
}
static void yaml_invalid_warning(const char* fmt, YAML::Node &node, std::string &file) {
void yaml_invalid_warning(const char* fmt, YAML::Node &node, std::string &file) {
YAML::Emitter out;
out << node;
ShowWarning(fmt, file.c_str());
@ -848,7 +852,7 @@ static void yaml_invalid_warning(const char* fmt, YAML::Node &node, std::string
/**
* Read inter config file
**/
static void inter_config_readConf(void) {
void inter_config_readConf(void) {
std::vector<std::string> directories = { "conf/", "conf/import/" };
static const std::string file_name(interserv_config.cfgFile);
@ -927,7 +931,7 @@ void inter_config_finalConf(void) {
}
static void inter_config_defaults(void) {
void inter_config_defaults(void) {
interserv_config.cfgFile = "inter_server.yml";
}
@ -1328,7 +1332,7 @@ int mapif_parse_RegistryRequest(int fd)
return 1;
}
static void mapif_namechange_ack(int fd, uint32 account_id, uint32 char_id, int type, int flag, char *name)
void mapif_namechange_ack(int fd, uint32 account_id, uint32 char_id, int type, int flag, char *name)
{
WFIFOHEAD(fd, NAME_LENGTH+13);
WFIFOW(fd, 0) = 0x3806;

View File

@ -5,22 +5,20 @@
#define _INTER_SQL_H_
#include "../common/cbasetypes.h"
#include "../common/conf.h"
#include "../common/mmo.h"
//#include "../common/conf.h"
//#include "../common/mmo.h"
#include "../common/sql.h"
#ifdef __cplusplus // C codes can't see this
#include <memory>
#include <string>
#include <unordered_map>
extern "C" {
struct s_storage_table;
struct Inter_Config {
std::string cfgFile; ///< Inter-Config file
std::unordered_map< uint8, std::shared_ptr<s_storage_table> > storages; ///< Storage name & table information
};
#endif
extern struct Inter_Config interserv_config;
@ -45,8 +43,5 @@ extern Sql* lsql_handle;
void inter_savereg(uint32 account_id, uint32 char_id, const char *key, unsigned int index, intptr_t val, bool is_string);
int inter_accreg_fromsql(uint32 account_id, uint32 char_id, int fd, int type);
#ifdef __cplusplus
}
#endif
#endif /* _INTER_SQL_H_ */