Various cleanups.

* Updated comments for chat.c and pet.c files.
* Cleaned up various other comments and stylization.
This commit is contained in:
aleos89 2014-10-02 12:49:04 -04:00
parent 2b870c24d5
commit a39f9ac8a2
24 changed files with 1320 additions and 559 deletions

View File

@ -51,7 +51,6 @@
#include <string.h>
#include <math.h>
#define ATCOMMAND_LENGTH 50
#define ACMD_FUNC(x) static int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message)

View File

@ -13,7 +13,8 @@ void cashshop_reloaddb( void );
bool cashshop_buylist( struct map_session_data* sd, uint32 kafrapoints, int n, uint16* item_list );
// Taken from AEGIS
enum CASH_SHOP_TAB_CODE{
enum CASH_SHOP_TAB_CODE
{
CASHSHOP_TAB_NEW = 0x0,
CASHSHOP_TAB_POPULAR = 0x1,
CASHSHOP_TAB_LIMITED = 0x2,
@ -26,7 +27,8 @@ enum CASH_SHOP_TAB_CODE{
};
// PACKET_ZC_SE_PC_BUY_CASHITEM_RESULT
enum CASHSHOP_BUY_RESULT{
enum CASHSHOP_BUY_RESULT
{
CASHSHOP_RESULT_SUCCESS = 0x0,
CASHSHOP_RESULT_ERROR_SYSTEM = 0x1,
CASHSHOP_RESULT_ERROR_SHORTTAGE_CASH = 0x2,
@ -42,7 +44,6 @@ enum CASHSHOP_BUY_RESULT{
CASHSHOP_RESULT_ERROR_BUSY = 0xc,
};
struct cash_item_data{
unsigned short nameid;
uint32 price;

View File

@ -19,7 +19,6 @@
#include <stdio.h>
#include <string.h>
int chat_triggerevent(struct chat_data *cd); // forward declaration
/// Initializes a chatroom object (common functionality for both pc and npc chatrooms).
@ -27,6 +26,7 @@ int chat_triggerevent(struct chat_data *cd); // forward declaration
static struct chat_data* chat_createchat(struct block_list* bl, const char* title, const char* pass, int limit, bool pub, int trigger, const char* ev, int zeny, int minLvl, int maxLvl)
{
struct chat_data* cd;
nullpo_retr(NULL, bl);
cd = (struct chat_data *) aMalloc(sizeof(struct chat_data));
@ -51,8 +51,7 @@ static struct chat_data* chat_createchat(struct block_list* bl, const char* titl
cd->bl.type = BL_CHAT;
cd->bl.next = cd->bl.prev = NULL;
if( cd->bl.id == 0 )
{
if( cd->bl.id == 0 ) {
aFree(cd);
cd = NULL;
}
@ -65,30 +64,33 @@ static struct chat_data* chat_createchat(struct block_list* bl, const char* titl
return cd;
}
/*==========================================
* player chatroom creation
*------------------------------------------*/
/**
* Player chat room creation.
* @param sd : player requesting
* @param title : title of chat room
* @param pass : password for chat room
* @param limit : amount allowed to enter
* @param pub : public or private
* @return 0
*/
int chat_createpcchat(struct map_session_data* sd, const char* title, const char* pass, int limit, bool pub)
{
struct chat_data* cd;
nullpo_ret(sd);
if( sd->chatID )
return 0; //Prevent people abusing the chat system by creating multiple chats, as pointed out by End of Exam. [Skotlex]
if( sd->state.vending || sd->state.buyingstore )
{// not chat, when you already have a store open
if( sd->state.vending || sd->state.buyingstore ) // not chat, when you already have a store open
return 0;
}
if( map[sd->bl.m].flag.nochat )
{
if( map[sd->bl.m].flag.nochat ) {
clif_displaymessage(sd->fd, msg_txt(sd,281));
return 0; //Can't create chatrooms on this map.
}
if( map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNOCHAT) )
{
if( map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNOCHAT) ) {
clif_displaymessage (sd->fd, msg_txt(sd,665));
return 0;
}
@ -96,6 +98,7 @@ int chat_createpcchat(struct map_session_data* sd, const char* title, const char
pc_stop_walking(sd,1);
cd = chat_createchat(&sd->bl, title, pass, limit, pub, 0, "", 0, 1, MAX_LEVEL);
if( cd ) {
cd->users = 1;
cd->usersd[0] = sd;
@ -109,24 +112,27 @@ int chat_createpcchat(struct map_session_data* sd, const char* title, const char
return 0;
}
/*==========================================
* join an existing chatroom
*------------------------------------------*/
/**
* Join an existing chat room.
* @param sd : player requesting
* @param chatid : ID of the chat room
* @param pass : password of chat room
* @return 0
*/
int chat_joinchat(struct map_session_data* sd, int chatid, const char* pass)
{
struct chat_data* cd;
nullpo_ret(sd);
cd = (struct chat_data*)map_id2bl(chatid);
if( cd == NULL || cd->bl.type != BL_CHAT || cd->bl.m != sd->bl.m || sd->state.vending || sd->state.buyingstore || sd->chatID || ((cd->owner->type == BL_NPC) ? cd->users+1 : cd->users) >= cd->limit )
{
if( cd == NULL || cd->bl.type != BL_CHAT || cd->bl.m != sd->bl.m || sd->state.vending || sd->state.buyingstore || sd->chatID || ((cd->owner->type == BL_NPC) ? cd->users+1 : cd->users) >= cd->limit ) {
clif_joinchatfail(sd,0);
return 0;
}
if( !cd->pub && strncmp(pass, cd->pass, sizeof(cd->pass)) != 0 && !pc_has_permission(sd, PC_PERM_JOIN_ALL_CHAT) )
{
if( !cd->pub && strncmp(pass, cd->pass, sizeof(cd->pass)) != 0 && !pc_has_permission(sd, PC_PERM_JOIN_ALL_CHAT) ) {
clif_joinchatfail(sd,1);
return 0;
}
@ -165,13 +171,12 @@ int chat_joinchat(struct map_session_data* sd, int chatid, const char* pass)
return 0;
}
/*==========================================
* Make player *sd leave a chatroom
* @param *sd : player pointer
/**
* Make player (sd) leave a chat room.
* @param sd : player requesting
* @param kicked : for clif notification, kicked=1 or regular leave
* @return 0:sucess, 1:failed
*------------------------------------------*/
* @return 0:success, 1:failed
*/
int chat_leavechat(struct map_session_data* sd, bool kicked)
{
struct chat_data* cd;
@ -181,15 +186,14 @@ int chat_leavechat(struct map_session_data* sd, bool kicked)
nullpo_retr(1, sd);
cd = (struct chat_data*)map_id2bl(sd->chatID);
if( cd == NULL )
{
if( cd == NULL ) {
pc_setchatid(sd, 0);
return 1;
}
ARR_FIND( 0, cd->users, i, cd->usersd[i] == sd );
if ( i == cd->users )
{ // Not found in the chatroom?
if ( i == cd->users ) { // Not found in the chatroom?
pc_setchatid(sd, 0);
return -1;
}
@ -203,7 +207,6 @@ int chat_leavechat(struct map_session_data* sd, bool kicked)
for( i = leavechar; i < cd->users; i++ )
cd->usersd[i] = cd->usersd[i+1];
if( cd->users == 0 && cd->owner->type == BL_PC ) { // Delete empty chatroom
struct skill_unit* unit;
struct skill_unit_group* group;
@ -216,14 +219,14 @@ int chat_leavechat(struct map_session_data* sd, bool kicked)
unit = map_find_skill_unit_oncell(&sd->bl, sd->bl.x, sd->bl.y, AL_WARP, NULL, 0);
group = (unit != NULL) ? unit->group : NULL;
if (group != NULL)
ext_skill_unit_onplace(unit, &sd->bl, group->tick);
return 1;
}
if( leavechar == 0 && cd->owner->type == BL_PC )
{ // Set and announce new owner
if( leavechar == 0 && cd->owner->type == BL_PC ) { // Set and announce new owner
cd->owner = (struct block_list*) cd->usersd[0];
clif_changechatowner(cd, cd->usersd[0]);
clif_clearchat(cd, 0);
@ -232,22 +235,23 @@ int chat_leavechat(struct map_session_data* sd, bool kicked)
map_delblock( &cd->bl );
cd->bl.x = cd->usersd[0]->bl.x;
cd->bl.y = cd->usersd[0]->bl.y;
if(map_addblock( &cd->bl ))
return 1;
clif_dispchat(cd,0);
}
else
} else
clif_dispchat(cd,0); // refresh chatroom
return 0;
}
/*==========================================
* change a chatroom's owner
* @param *sd : player pointer
* @param *nextownername : string of new owner (name should be in chatroom)
* @return 0:sucess, 1:failure
*------------------------------------------*/
/**
* Change a chat room's owner.
* @param sd : player requesting
* @param nextownername : string of new owner (name should be in chatroom)
* @return 0:success, 1:failure
*/
int chat_changechatowner(struct map_session_data* sd, const char* nextownername)
{
struct chat_data* cd;
@ -257,6 +261,7 @@ int chat_changechatowner(struct map_session_data* sd, const char* nextownername)
nullpo_retr(1, sd);
cd = (struct chat_data*)map_id2bl(sd->chatID);
if( cd == NULL || (struct block_list*) sd != cd->owner )
return 1;
@ -280,6 +285,7 @@ int chat_changechatowner(struct map_session_data* sd, const char* nextownername)
map_delblock( &cd->bl );
cd->bl.x = cd->owner->x;
cd->bl.y = cd->owner->y;
if(map_addblock( &cd->bl ))
return 1;
@ -289,9 +295,15 @@ int chat_changechatowner(struct map_session_data* sd, const char* nextownername)
return 0;
}
/*==========================================
* change a chatroom's status (title, etc)
*------------------------------------------*/
/**
* Change a chat room's status (title, etc).
* @param sd : player requesting
* @param title : new title
* @param pass : new password
* @param limit : new limit
* @param pub : public or private
* @return 1:success, 0:failure
*/
int chat_changechatstatus(struct map_session_data* sd, const char* title, const char* pass, int limit, bool pub)
{
struct chat_data* cd;
@ -299,6 +311,7 @@ int chat_changechatstatus(struct map_session_data* sd, const char* title, const
nullpo_retr(1, sd);
cd = (struct chat_data*)map_id2bl(sd->chatID);
if( cd == NULL || (struct block_list *)sd != cd->owner )
return 1;
@ -313,9 +326,12 @@ int chat_changechatstatus(struct map_session_data* sd, const char* title, const
return 0;
}
/*==========================================
* kick an user from a chatroom
*------------------------------------------*/
/**
* Kick a member from a chat room.
* @param sd : player requesting
* @param kickusername : player name to be kicked
* @retur 1:success, 0:failure
*/
int chat_kickchat(struct map_session_data* sd, const char* kickusername)
{
struct chat_data* cd;
@ -338,13 +354,27 @@ int chat_kickchat(struct map_session_data* sd, const char* kickusername)
idb_put(cd->kick_list,cd->usersd[i]->status.char_id,(void*)1);
chat_leavechat(cd->usersd[i],1);
return 0;
}
/// Creates a chat room for the npc.
/**
* Creates a chat room for a NPC.
* @param nd : NPC requesting
* @param title : title of chat room
* @param limit : limit of users in chat room
* @param pub : public or private
* @param trigger : event trigger
* @param ev : event name
* @param zeny : zeny cost
* @param minLvl : minimum level to enter
* @param maxLvl : maximum level to enter
* @return 0
*/
int chat_createnpcchat(struct npc_data* nd, const char* title, int limit, bool pub, int trigger, const char* ev, int zeny, int minLvl, int maxLvl)
{
struct chat_data* cd;
nullpo_ret(nd);
if( nd->chat_id ) {
@ -367,13 +397,18 @@ int chat_createnpcchat(struct npc_data* nd, const char* title, int limit, bool p
return 0;
}
/// Removes the chatroom from the npc.
/**
* Removes a chat room for a NPC.
* @param nd : NPC requesting
*/
int chat_deletenpcchat(struct npc_data* nd)
{
struct chat_data *cd;
nullpo_ret(nd);
cd = (struct chat_data*)map_id2bl(nd->chat_id);
if( cd == NULL )
return 0;
@ -387,39 +422,53 @@ int chat_deletenpcchat(struct npc_data* nd)
return 0;
}
/*==========================================
* Trigger npc event when we enter the chatroom
*------------------------------------------*/
/**
* Trigger NPC event when entering the chat room.
* @param cd : chat room to trigger event
* @return 0
*/
int chat_triggerevent(struct chat_data *cd)
{
nullpo_ret(cd);
if( cd->users >= cd->trigger && cd->npc_event[0] )
npc_event_do(cd->npc_event);
return 0;
}
/// Enables the event of the chat room.
/// At most, 127 users are needed to trigger the event.
/**
* Enables the event of the chat room.
* At most, 127 users are needed to trigger the event.
* @param cd : chat room to trigger event
*/
int chat_enableevent(struct chat_data* cd)
{
nullpo_ret(cd);
cd->trigger &= 0x7f;
chat_triggerevent(cd);
return 0;
}
/// Disables the event of the chat room
/**
* Disables the event of the chat room.
* @param cd : chat room to trigger event
*/
int chat_disableevent(struct chat_data* cd)
{
nullpo_ret(cd);
cd->trigger |= 0x80;
return 0;
}
/// Kicks all the users from the chat room.
/**
* Kicks all the users from the chat room.
* @param cd : chat room to trigger event
*/
int chat_npckickall(struct chat_data* cd)
{
nullpo_ret(cd);

View File

@ -29,7 +29,6 @@
#include <stdlib.h>
#include <string.h>
static DBMap* guild_db; // int guild_id -> struct guild*
static DBMap* castle_db; // int castle_id -> struct guild_castle*
static DBMap* guild_expcache_db; // int char_id -> struct guild_expcache*

View File

@ -11,7 +11,8 @@
typedef enum instance_state { INSTANCE_FREE, INSTANCE_IDLE, INSTANCE_BUSY } instance_state;
struct instance_data {
struct instance_data
{
short type, cnt_map;
int state;
int party_id;

View File

@ -32,7 +32,6 @@
#include <fcntl.h>
#include <string.h>
static const int packet_len_table[]={
-1,-1,27,-1, -1, 0,37,-1, 0, 0, 0, 0, 0, 0, 0, 0, //0x3800-0x380f
0, 0, 0, 0, 0, 0, 0, 0, -1,11, 0, 0, 0, 0, 0, 0, //0x3810

View File

@ -30,7 +30,6 @@ int intif_request_registry(struct map_session_data *sd, int flag);
int intif_request_guild_storage(int account_id, int guild_id);
int intif_send_guild_storage(int account_id, struct guild_storage *gstor);
int intif_create_party(struct party_member *member,char *name,int item,int item2);
int intif_request_partyinfo(int party_id, int char_id);
@ -43,7 +42,6 @@ int intif_party_message(int party_id, int account_id, const char *mes,int len);
int intif_party_leaderchange(int party_id,int account_id,int char_id);
int intif_party_sharelvlupdate(unsigned int share_lvl);
int intif_guild_create(const char *name, const struct guild_member *master);
int intif_guild_request_info(int guild_id);
int intif_guild_addmember(int guild_id, struct guild_member *m);

View File

@ -33,7 +33,8 @@
#define itemdb_isspecial(i) (i == CARD0_FORGE || i == CARD0_CREATE || i == CARD0_PET)
///Enum of item id (for hardcoded purpose)
enum item_itemid {
enum item_itemid
{
ITEMID_RED_POTION = 501,
ITEMID_YELLOW_POTION = 503,
ITEMID_WHITE_POTION = 504,
@ -122,7 +123,8 @@ enum item_itemid {
};
///Mercenary Scrolls
enum mercenary_scroll_item_list {
enum mercenary_scroll_item_list
{
ITEMID_BOW_MERCENARY_SCROLL1 = 12153,
ITEMID_BOW_MERCENARY_SCROLL2,
ITEMID_BOW_MERCENARY_SCROLL3,
@ -156,7 +158,8 @@ enum mercenary_scroll_item_list {
};
///Rune Knight
enum rune_item_list {
enum rune_item_list
{
ITEMID_NAUTHIZ = 12725,
ITEMID_RAIDO,
ITEMID_BERKANA,
@ -170,7 +173,8 @@ enum rune_item_list {
};
///Mechanic
enum mechanic_item_list {
enum mechanic_item_list
{
ITEMID_ACCELERATOR = 2800,
ITEMID_HOVERING_BOOSTER,
ITEMID_SUICIDAL_DEVICE,
@ -192,7 +196,8 @@ enum mechanic_item_list {
};
///Genetic
enum genetic_item_list {
enum genetic_item_list
{
ITEMID_SEED_OF_HORNY_PLANT = 6210,
ITEMID_BLOODSUCK_PLANT_SEED = 6211,
ITEMID_BOMB_MUSHROOM_SPORE = 6212,
@ -247,7 +252,8 @@ enum genetic_item_list {
};
///Guillotine Cross
enum poison_item_list {
enum poison_item_list
{
ITEMID_PARALYSE = 12717,
ITEMID_LEECHESEND,
ITEMID_OBLIVIONCURSE,
@ -259,7 +265,8 @@ enum poison_item_list {
};
///Spell Books
enum spell_book_item_list {
enum spell_book_item_list
{
ITEMID_MAGIC_BOOK_FB = 6189,
ITEMID_MAGIC_BOOK_CB,
ITEMID_MAGIC_BOOK_LB,
@ -280,7 +287,8 @@ enum spell_book_item_list {
};
///Cash Food
enum cash_food_item_list {
enum cash_food_item_list
{
ITEMID_STR_DISH10_ = 12202,
ITEMID_AGI_DISH10_,
ITEMID_INT_DISH10_,
@ -290,12 +298,14 @@ enum cash_food_item_list {
};
///Item No Use List
enum item_nouse_list {
enum item_nouse_list
{
NOUSE_SITTING = 0x01,
};
///Item job
enum e_item_job {
enum e_item_job
{
ITEMJ_NORMAL = 0x01,
ITEMJ_UPPER = 0x02,
ITEMJ_BABY = 0x04,
@ -304,7 +314,8 @@ enum e_item_job {
ITEMJ_THIRD_BABY = 0x20,
};
enum e_item_ammo {
enum e_item_ammo
{
AMMO_ARROW = 1,
AMMO_THROWABLE_DAGGER,
AMMO_BULLET,
@ -317,7 +328,8 @@ enum e_item_ammo {
};
///Item combo struct
struct item_combo {
struct item_combo
{
struct script_code *script;
unsigned short *nameid;/* nameid array */
unsigned char count;
@ -327,7 +339,8 @@ struct item_combo {
/// Struct of item group entry
struct s_item_group_entry {
struct s_item_group_entry
{
unsigned short nameid, /// Item ID
duration, /// Duration if item as rental item (in minutes)
amount; /// Amount of item will be obtained
@ -337,13 +350,15 @@ struct s_item_group_entry {
};
/// Struct of random group
struct s_item_group_random {
struct s_item_group_random
{
struct s_item_group_entry *data; /// Random group entry
unsigned short data_qty; /// Number of item in random group
};
/// Struct of item group that will be used for db
struct s_item_group_db {
struct s_item_group_db
{
unsigned short id, /// Item Group ID
must_qty; /// Number of must item at this group
struct s_item_group_entry *must; /// Must item entry
@ -351,7 +366,8 @@ struct s_item_group_db {
};
///Main item data struct
struct item_data {
struct item_data
{
unsigned short nameid;
char name[ITEM_NAME_LENGTH],jname[ITEM_NAME_LENGTH];

View File

@ -17,7 +17,6 @@
#include <stdlib.h>
#include <string.h>
/// filters for item logging
typedef enum e_log_filter
{

View File

@ -10,7 +10,6 @@ struct map_session_data;
struct mob_data;
struct item;
typedef enum e_log_chat_type
{
LOG_CHAT_GLOBAL = 0x01,
@ -20,9 +19,7 @@ typedef enum e_log_chat_type
LOG_CHAT_MAINCHAT = 0x10,
// all
LOG_CHAT_ALL = 0xFF,
}
e_log_chat_type;
} e_log_chat_type;
typedef enum e_log_pick_type
{
@ -50,10 +47,10 @@ typedef enum e_log_pick_type
LOG_TYPE_LOOT = LOG_TYPE_PICKDROP_MONSTER|LOG_TYPE_CONSUME,
// all
LOG_TYPE_ALL = 0xFFFFF,
}
e_log_pick_type;
} e_log_pick_type;
typedef enum e_log_cash_type{
typedef enum e_log_cash_type
{
LOG_CASH_TYPE_CASH = 0x1,
LOG_CASH_TYPE_KAFRA = 0x2
} e_log_cash_type;
@ -83,8 +80,7 @@ extern struct Log_Config
int rare_items_log,refine_items_log,price_items_log,amount_items_log; //for filter
int branch, mvpdrop, zeny, commands, npc, chat;
char log_branch[64], log_pick[64], log_zeny[64], log_mvpdrop[64], log_gm[64], log_npc[64], log_chat[64], log_cash[64];
}
log_config;
} log_config;
#ifdef BETA_THREAD_TEST
struct {

View File

@ -20,7 +20,6 @@ static char mapreg_table[32] = "mapreg";
static bool mapreg_dirty = false;
#define MAPREG_AUTOSAVE_INTERVAL (300*1000)
/// Looks up the value of an integer variable using its uid.
int mapreg_readreg(int uid)
{

View File

@ -36,7 +36,6 @@
#include <time.h>
#include <errno.h>
struct npc_data* fake_nd;
// linked list of npc source files

View File

@ -7,11 +7,11 @@
#include "map.h" // struct block_list
#include "status.h" // struct status_change
#include "unit.h" // struct unit_data
struct block_list;
struct npc_data;
struct view_data;
struct npc_timerevent_list {
int timer,pos;
};
@ -76,8 +76,6 @@ struct npc_data {
} u;
};
#define START_NPC_NUM 110000000
enum actor_classes

View File

@ -21,7 +21,6 @@
#include <string.h>
#include <stdarg.h>
/**
* Written by MouseJstr in a vision... (2/21/2005)
*

View File

@ -13,7 +13,6 @@
#include "pc_groups.h"
#include "pc.h" // e_pc_permission
typedef struct GroupSettings GroupSettings;
// Cached config settings/pointers for quick lookup

File diff suppressed because it is too large Load Diff

View File

@ -34,8 +34,7 @@
/**
* Searches a quest by ID.
*
* @param quest_id ID to lookup
* @param quest_id : ID to lookup
* @return Quest entry (equals to &quest_dummy if the ID is invalid)
*/
struct quest_db *quest_db(int quest_id)
@ -48,8 +47,7 @@ struct quest_db *quest_db(int quest_id)
/**
* Sends quest info to the player on login.
*
* @param sd Player's data
* @param sd : Player's data
* @return 0 in case of success, nonzero otherwise (i.e. the player has no quests)
*/
int quest_pc_login(TBL_PC *sd)
@ -71,11 +69,9 @@ int quest_pc_login(TBL_PC *sd)
/**
* Adds a quest to the player's list.
*
* New quest will be added as Q_ACTIVE.
*
* @param sd Player's data
* @param quest_id ID of the quest to add.
* @param sd : Player's data
* @param quest_id : ID of the quest to add.
* @return 0 in case of success, nonzero otherwise
*/
int quest_add(TBL_PC *sd, int quest_id)
@ -123,10 +119,9 @@ int quest_add(TBL_PC *sd, int quest_id)
/**
* Replaces a quest in a player's list with another one.
*
* @param sd Player's data
* @param qid1 Current quest to replace
* @param qid2 New quest to add
* @param sd : Player's data
* @param qid1 : Current quest to replace
* @param qid2 : New quest to add
* @return 0 in case of success, nonzero otherwise
*/
int quest_change(TBL_PC *sd, int qid1, int qid2)
@ -177,9 +172,8 @@ int quest_change(TBL_PC *sd, int qid1, int qid2)
/**
* Removes a quest from a player's list
*
* @param sd Player's data
* @param quest_id ID of the quest to remove
* @param sd : Player's data
* @param quest_id : ID of the quest to remove
* @return 0 in case of success, nonzero otherwise
*/
int quest_delete(TBL_PC *sd, int quest_id)
@ -217,9 +211,8 @@ int quest_delete(TBL_PC *sd, int quest_id)
/**
* Map iterator subroutine to update quest objectives for a party after killing a monster.
*
* @see map_foreachinrange
* @param ap Argument list, expecting:
* @param ap : Argument list, expecting:
* int Party ID
* int Mob ID
*/
@ -246,9 +239,8 @@ int quest_update_objective_sub(struct block_list *bl, va_list ap)
/**
* Updates the quest objectives for a character after killing a monster.
*
* @param sd Character's data
* @param mob_id Monster ID
* @param sd : Character's data
* @param mob_id : Monster ID
*/
void quest_update_objective(TBL_PC *sd, int mob)
{
@ -274,13 +266,12 @@ void quest_update_objective(TBL_PC *sd, int mob)
/**
* Updates a quest's state.
*
* Only status of active and inactive quests can be updated. Completed quests can't (for now). [Inkfish]
*
* @param sd Character's data
* @param quest_id Quest ID to update
* @param qs New quest state
* Only status of active and inactive quests can be updated. Completed quests can't (for now).
* @param sd : Character's data
* @param quest_id : Quest ID to update
* @param qs : New quest state
* @return 0 in case of success, nonzero otherwise
* @author [Inkfish]
*/
int quest_update_status(TBL_PC *sd, int quest_id, enum quest_state status)
{
@ -319,10 +310,9 @@ int quest_update_status(TBL_PC *sd, int quest_id, enum quest_state status)
/**
* Queries quest information for a character.
*
* @param sd Character's data
* @param quest_id Quest ID
* @param type Check type
* @param sd : Character's data
* @param quest_id : Quest ID
* @param type : Check type
* @return -1 if the quest was not found, otherwise it depends on the type:
* HAVEQUEST: The quest's state
* PLAYTIME: 2 if the quest's timeout has expired
@ -367,7 +357,6 @@ int quest_check(TBL_PC *sd, int quest_id, enum quest_check_type type)
/**
* Loads quests from the quest db.
*
* @return Number of loaded quests, or -1 if the file couldn't be read.
*/
int quest_read_db(void)
@ -453,11 +442,10 @@ int quest_read_db(void)
/**
* Map iterator to ensures a player has no invalid quest log entries.
*
* Any entries that are no longer in the db are removed.
*
* @see map_foreachpc
* @param ap Ignored
* @param sd : Character's data
* @param ap : Ignored
*/
int quest_reload_check_sub(struct map_session_data *sd, va_list ap)
{

View File

@ -73,7 +73,6 @@
#include "../common/mutex.h"
#endif
///////////////////////////////////////////////////////////////////////////////
//## TODO possible enhancements: [FlavioJS]
// - 'callfunc' supporting labels in the current npc "::LabelName"

View File

@ -10,8 +10,7 @@
#include "pc.h" // struct map_session_data
#include "searchstore.h" // struct s_search_store_info
/// failure constants for clif functions
/// Failure constants for clif functions
enum e_searchstore_failure
{
SSI_FAILED_NOTHING_SEARCH_ITEM = 0, // "No matching stores were found."
@ -21,13 +20,14 @@ enum e_searchstore_failure
SSI_FAILED_SSILIST_CLICK_TO_OPEN_STORE = 4, // "No sale (purchase) information available."
};
/// Search type constants
enum e_searchstore_searchtype
{
SEARCHTYPE_VENDING = 0,
SEARCHTYPE_BUYING_STORE = 1,
};
/// Search effect constants
enum e_searchstore_effecttype
{
EFFECTTYPE_NORMAL = 0,
@ -35,11 +35,15 @@ enum e_searchstore_effecttype
EFFECTTYPE_MAX
};
/// type for shop search function
/// Type for shop search function
typedef bool (*searchstore_search_t)(struct map_session_data* sd, unsigned short nameid);
typedef bool (*searchstore_searchall_t)(struct map_session_data* sd, const struct s_search_store_search* s);
/// retrieves search function by type
/**
* Retrieves search function by type.
* @param type : type of search to conduct
* @return : search type
*/
static searchstore_search_t searchstore_getsearchfunc(unsigned char type)
{
switch( type ) {
@ -50,7 +54,11 @@ static searchstore_search_t searchstore_getsearchfunc(unsigned char type)
return NULL;
}
/// retrieves search-all function by type
/**
* Retrieves search-all function by type.
* @param type : type of search to conduct
* @return : search type
*/
static searchstore_searchall_t searchstore_getsearchallfunc(unsigned char type)
{
switch( type ) {
@ -61,7 +69,12 @@ static searchstore_searchall_t searchstore_getsearchallfunc(unsigned char type)
return NULL;
}
/// checks if the player has a store by type
/**
* Checks if the player has a store by type.
* @param sd : player requesting
* @param type : type of search to conduct
* @return : store type
*/
static bool searchstore_hasstore(struct map_session_data* sd, unsigned char type)
{
switch( type ) {
@ -72,7 +85,12 @@ static bool searchstore_hasstore(struct map_session_data* sd, unsigned char type
return false;
}
/// returns player's store id by type
/**
* Returns player's store ID by type.
* @param sd : player requesting
* @param type : type of search to conduct
* @return : store ID
*/
static int searchstore_getstoreid(struct map_session_data* sd, unsigned char type)
{
switch( type ) {
@ -83,6 +101,13 @@ static int searchstore_getstoreid(struct map_session_data* sd, unsigned char typ
return 0;
}
/**
* Send request to open Search Store.
* @param sd : player requesting
* @param uses : uses left to open
* @param effect : shop type
* @return : true : opened, false : failed to open
*/
bool searchstore_open(struct map_session_data* sd, unsigned int uses, unsigned short effect)
{
if( !battle_config.feature_search_stores || sd->searchstore.open )
@ -100,6 +125,17 @@ bool searchstore_open(struct map_session_data* sd, unsigned int uses, unsigned s
return true;
}
/**
* Query and present the results for the item.
* @param sd : player requesting
* @param type : shop type
* @param min_price : minimum zeny price
* @param max_price : maximum zeny price
* @param itemlist : list with stored item results
* @param item_count : amount of items in itemlist
* @param cardlist : list with stored cards (cards attached to items)
* @param card_count : amount of items in cardlist
*/
void searchstore_query(struct map_session_data* sd, unsigned char type, unsigned int min_price, unsigned int max_price, const unsigned short* itemlist, unsigned int item_count, const unsigned short* cardlist, unsigned int card_count)
{
unsigned int i;
@ -204,7 +240,11 @@ void searchstore_query(struct map_session_data* sd, unsigned char type, unsigned
}
}
/// checks whether or not more results are available for the client
/**
* Checks whether or not more results are available for the client.
* @param sd : player requesting
* @return : true : more items to search, false : no more items
*/
bool searchstore_querynext(struct map_session_data* sd)
{
if( sd->searchstore.count && ( sd->searchstore.count-1 )/SEARCHSTORE_RESULTS_PER_PAGE < sd->searchstore.pages )
@ -213,12 +253,14 @@ bool searchstore_querynext(struct map_session_data* sd)
return false;
}
/**
* Get and display the results for the next page.
* @param sd : player requesting
*/
void searchstore_next(struct map_session_data* sd)
{
if( !battle_config.feature_search_stores || !sd->searchstore.open || sd->searchstore.count <= sd->searchstore.pages*SEARCHSTORE_RESULTS_PER_PAGE )
{// nothing (more) to display
if( !battle_config.feature_search_stores || !sd->searchstore.open || sd->searchstore.count <= sd->searchstore.pages*SEARCHSTORE_RESULTS_PER_PAGE ) // nothing (more) to display
return;
}
// present results
clif_search_store_info_ack(sd);
@ -227,6 +269,10 @@ void searchstore_next(struct map_session_data* sd)
sd->searchstore.pages++;
}
/**
* Prepare to clear information for closing of window.
* @param sd : player requesting
*/
void searchstore_clear(struct map_session_data* sd)
{
searchstore_clearremote(sd);
@ -240,7 +286,10 @@ void searchstore_clear(struct map_session_data* sd)
sd->searchstore.pages = 0;
}
/**
* Close the Search Store window.
* @param sd : player requesting
*/
void searchstore_close(struct map_session_data* sd)
{
if( sd->searchstore.open ) {
@ -251,7 +300,13 @@ void searchstore_close(struct map_session_data* sd)
}
}
/**
* Process the actions (click) for the Search Store window.
* @param sd : player requesting
* @param account_id : account ID of owner's shop
* @param store_id : store ID created by client
* @param nameid : item being searched
*/
void searchstore_click(struct map_session_data* sd, int account_id, int store_id, unsigned short nameid)
{
unsigned int i;
@ -311,19 +366,38 @@ void searchstore_click(struct map_session_data* sd, int account_id, int store_id
}
}
/// checks whether or not sd has opened account_id's shop remotely
/**
* Checks whether or not sd has opened account_id's shop remotely.
* @param sd : player requesting
* @param account_id : account ID of owner's shop
* @return : true : shop opened, false : shop not opened
*/
bool searchstore_queryremote(struct map_session_data* sd, int account_id)
{
return (bool)( sd->searchstore.open && sd->searchstore.count && sd->searchstore.remote_id == account_id );
}
/// removes range-check bypassing for remotely opened stores
/**
* Removes range-check bypassing for remotely opened stores.
* @param sd : player requesting
*/
void searchstore_clearremote(struct map_session_data* sd)
{
sd->searchstore.remote_id = 0;
}
/// receives results from a store-specific callback
/**
* Receives results from a store-specific callback.
* @param sd : player requesting
* @param store_id : store ID generated by the client
* @param account_id : account ID of owner's shop
* @param store_name : name of store
* @param nameid : item being searched
* @param amount : count of item
* @param price : zeny price of item
* @param card : card in the item
* @param refine : refine of the item
*/
bool searchstore_result(struct map_session_data* sd, int store_id, int account_id, const char* store_name, unsigned short nameid, unsigned short amount, unsigned int price, const unsigned short* card, unsigned char refine)
{
struct s_search_store_info_item* ssitem;

View File

@ -41,7 +41,6 @@
#include <time.h>
#include <math.h>
#define SKILLUNITTIMER_INTERVAL 100
// ranges reserved for mapping skill ids to skilldb offsets

View File

@ -23,7 +23,6 @@
#include <stdlib.h>
#include <string.h>
static DBMap* guild_storage_db; ///Databases of guild_storage : int guild_id -> struct guild_storage*
/**
@ -44,6 +43,7 @@ static int storage_comp_item(const void *_i1, const void *_i2)
return 1;
else if (!(i2->nameid) || !(i2->amount))
return -1;
return i1->nameid - i2->nameid;
}
@ -89,6 +89,7 @@ void do_final_storage(void)
static int storage_reconnect_sub(DBKey key, DBData *data, va_list ap)
{
struct guild_storage *stor = db_data2ptr(data);
if (stor->dirty && stor->storage_status == 0) //Save closed storages.
storage_guild_storagesave(0, stor->guild_id,0);
@ -116,8 +117,7 @@ int storage_storageopen(struct map_session_data *sd)
if(sd->state.storage_flag)
return 1; //Already open?
if( !pc_can_give_items(sd) )
{ //check is this GM level is allowed to put items to storage
if( !pc_can_give_items(sd) ) { // check is this GM level is allowed to put items to storage
clif_displaymessage(sd->fd, msg_txt(sd,246));
return 1;
}
@ -126,6 +126,7 @@ int storage_storageopen(struct map_session_data *sd)
storage_sortitem(sd->status.storage.items, ARRAYLENGTH(sd->status.storage.items));
clif_storagelist(sd, sd->status.storage.items, ARRAYLENGTH(sd->status.storage.items));
clif_updatestorageamount(sd, sd->status.storage.storage_amount, sd->storage_size);
return 0;
}
@ -142,12 +143,14 @@ int compare_item(struct item *a, struct item *b)
a->refine == b->refine &&
a->attribute == b->attribute &&
a->expire_time == b->expire_time &&
a->bound == b->bound )
{
a->bound == b->bound ) {
int i;
for (i = 0; i < MAX_SLOTS && (a->card[i] == b->card[i]); i++);
return (i == MAX_SLOTS);
}
return 0;
}
@ -169,13 +172,10 @@ static int storage_additem(struct map_session_data* sd, struct item* item_data,
data = itemdb_search(item_data->nameid);
if( data->stack.storage && amount > data->stack.amount )
{// item stack limitation
if( data->stack.storage && amount > data->stack.amount ) // item stack limitation
return 1;
}
if( !itemdb_canstore(item_data, pc_get_group_level(sd)) )
{ //Check if item is storable. [Skotlex]
if( !itemdb_canstore(item_data, pc_get_group_level(sd)) ) { // Check if item is storable. [Skotlex]
clif_displaymessage (sd->fd, msg_txt(sd,264));
return 1;
}
@ -185,16 +185,15 @@ static int storage_additem(struct map_session_data* sd, struct item* item_data,
return 1;
}
if( itemdb_isstackable2(data) )
{//Stackable
for( i = 0; i < sd->storage_size; i++ )
{
if( compare_item(&stor->items[i], item_data) )
{// existing items found, stack them
if( itemdb_isstackable2(data) ) { // Stackable
for( i = 0; i < sd->storage_size; i++ ) {
if( compare_item(&stor->items[i], item_data) ) { // existing items found, stack them
if( amount > MAX_AMOUNT - stor->items[i].amount || ( data->stack.storage && amount > data->stack.amount - stor->items[i].amount ) )
return 1;
stor->items[i].amount += amount;
clif_storageitemadded(sd,&stor->items[i],i,amount);
return 0;
}
}
@ -228,13 +227,18 @@ int storage_delitem(struct map_session_data* sd, int n, int amount)
return 1;
sd->status.storage.items[n].amount -= amount;
if( sd->status.storage.items[n].amount == 0 )
{
if( sd->status.storage.items[n].amount == 0 ) {
memset(&sd->status.storage.items[n],0,sizeof(sd->status.storage.items[0]));
sd->status.storage.storage_amount--;
if( sd->state.storage_flag == 1 ) clif_updatestorageamount(sd, sd->status.storage.storage_amount, sd->storage_size);
if( sd->state.storage_flag == 1 )
clif_updatestorageamount(sd, sd->status.storage.storage_amount, sd->storage_size);
}
if( sd->state.storage_flag == 1 ) clif_storageitemremoved(sd,n,amount);
if( sd->state.storage_flag == 1 )
clif_storageitemremoved(sd,n,amount);
return 0;
}
@ -338,6 +342,7 @@ void storage_storageaddfromcart(struct map_session_data* sd, int index, int amou
void storage_storagegettocart(struct map_session_data* sd, int index, int amount)
{
unsigned char flag;
nullpo_retv(sd);
if( index < 0 || index >= sd->storage_size )
@ -379,8 +384,8 @@ void storage_storageclose(struct map_session_data* sd)
* Force closing the storage for player without displaying result
* (exemple when quitting the game)
* @param sd : player to close storage
* @param flag : \n
* 1: Character is quitting \n
* @param flag :
* 1: Character is quitting
* 2(x): Character is changing map-servers
*/
void storage_storage_quit(struct map_session_data* sd, int flag)
@ -403,8 +408,10 @@ void storage_storage_quit(struct map_session_data* sd, int flag)
static DBData create_guildstorage(DBKey key, va_list args)
{
struct guild_storage *gs = NULL;
gs = (struct guild_storage *) aCalloc(sizeof(struct guild_storage), 1);
gs->guild_id=key.i;
return db_ptr2data(gs);
}
@ -417,8 +424,10 @@ static DBData create_guildstorage(DBKey key, va_list args)
struct guild_storage *guild2storage(int guild_id)
{
struct guild_storage *gs = NULL;
if(guild_search(guild_id) != NULL)
gs = idb_ensure(guild_storage_db,guild_id,create_guildstorage);
return gs;
}
@ -441,13 +450,14 @@ struct guild_storage *guild2storage2(int guild_id)
int guild_storage_delete(int guild_id)
{
idb_remove(guild_storage_db,guild_id);
return 0;
}
/**
* Attempt to open guild storage for player
* @param sd : player
* @return * 0 : success, 1 : fail, 2 : no guild found
* @return 0 : success, 1 : fail, 2 : no guild found
*/
int storage_guild_storageopen(struct map_session_data* sd)
{
@ -470,6 +480,7 @@ int storage_guild_storageopen(struct map_session_data* sd)
intif_request_guild_storage(sd->status.account_id,sd->status.guild_id);
return 0;
}
if(gstor->storage_status)
return 1;
@ -481,6 +492,7 @@ int storage_guild_storageopen(struct map_session_data* sd)
storage_sortitem(gstor->items, ARRAYLENGTH(gstor->items));
clif_storagelist(sd, gstor->items, ARRAYLENGTH(gstor->items));
clif_updatestorageamount(sd, gstor->storage_amount, MAX_GUILD_STORAGE);
return 0;
}
@ -506,13 +518,10 @@ char guild_storage_additem(struct map_session_data* sd, struct guild_storage* st
data = itemdb_search(item_data->nameid);
if( data->stack.guildstorage && amount > data->stack.amount )
{// item stack limitation
if( data->stack.guildstorage && amount > data->stack.amount ) // item stack limitation
return 1;
}
if( !itemdb_canguildstore(item_data, pc_get_group_level(sd)) || item_data->expire_time )
{ //Check if item is storable. [Skotlex]
if( !itemdb_canguildstore(item_data, pc_get_group_level(sd)) || item_data->expire_time ) { // Check if item is storable. [Skotlex]
clif_displaymessage (sd->fd, msg_txt(sd,264));
return 1;
}
@ -527,13 +536,16 @@ char guild_storage_additem(struct map_session_data* sd, struct guild_storage* st
if(compare_item(&stor->items[i], item_data)) {
if( amount > MAX_AMOUNT - stor->items[i].amount || ( data->stack.guildstorage && amount > data->stack.amount - stor->items[i].amount ) )
return 1;
stor->items[i].amount+=amount;
clif_storageitemadded(sd,&stor->items[i],i,amount);
stor->dirty = 1;
return 0;
}
}
}
//Add item
for(i = 0; i < MAX_GUILD_STORAGE && stor->items[i].nameid; i++);
@ -546,6 +558,7 @@ char guild_storage_additem(struct map_session_data* sd, struct guild_storage* st
clif_storageitemadded(sd,&stor->items[i],i,amount);
clif_updatestorageamount(sd, stor->storage_amount, MAX_GUILD_STORAGE);
stor->dirty = 1;
return 0;
}
@ -566,13 +579,16 @@ int guild_storage_delitem(struct map_session_data* sd, struct guild_storage* sto
return 1;
stor->items[n].amount -= amount;
if(stor->items[n].amount == 0) {
memset(&stor->items[n],0,sizeof(stor->items[0]));
stor->storage_amount--;
clif_updatestorageamount(sd, stor->storage_amount, MAX_GUILD_STORAGE);
}
clif_storageitemremoved(sd,n,amount);
stor->dirty = 1;
return 0;
}
@ -692,7 +708,7 @@ void storage_guild_storageaddfromcart(struct map_session_data* sd, int index, in
* Attempt to retrieve an item from guild storage to cart, then refresh it
* @param sd : player
* @param index : index of item in storage
* @param amount : number of item to transfert
* @param amount : number of item to transfer
* @return 1:fail, 0:success
*/
void storage_guild_storagegettocart(struct map_session_data* sd, int index, int amount)
@ -734,33 +750,35 @@ int storage_guild_storagesave(int account_id, int guild_id, int flag)
{
struct guild_storage *stor = guild2storage2(guild_id);
if(stor)
{
if(stor) {
if (flag) //Char quitting, close it.
stor->storage_status = 0;
if (stor->dirty)
intif_send_guild_storage(account_id,stor);
return 1;
}
return 0;
}
/**
* ACK save of guild storage
* @param guild_id : guild to use the storage
* @return 0 : fail (no storage), 1 : succes
* @return 0 : fail (no storage), 1 : success
*/
int storage_guild_storagesaved(int guild_id)
{
struct guild_storage *stor;
if((stor = guild2storage2(guild_id)) != NULL) {
if (stor->dirty && stor->storage_status == 0)
{ //Storage has been correctly saved.
if (stor->dirty && stor->storage_status == 0) // Storage has been correctly saved.
stor->dirty = 0;
}
return 1;
}
return 0;
}
@ -777,14 +795,15 @@ int storage_guild_storageclose(struct map_session_data* sd)
nullpo_ret(stor = guild2storage2(sd->status.guild_id));
clif_storageclose(sd);
if (stor->storage_status)
{
if (stor->storage_status) {
if (save_settings&4)
chrif_save(sd, 0); //This one also saves the storage. [Skotlex]
else
storage_guild_storagesave(sd->status.account_id, sd->status.guild_id,0);
stor->storage_status=0;
}
sd->state.storage_flag = 0;
return 0;
@ -803,13 +822,14 @@ int storage_guild_storage_quit(struct map_session_data* sd, int flag)
nullpo_ret(sd);
nullpo_ret(stor=guild2storage2(sd->status.guild_id));
if(flag)
{ //Only during a guild break flag is 1 (don't save storage)
if(flag) { // Only during a guild break flag is 1 (don't save storage)
sd->state.storage_flag = 0;
stor->storage_status = 0;
clif_storageclose(sd);
if (save_settings&4)
chrif_save(sd,0);
return 0;
}
@ -819,6 +839,7 @@ int storage_guild_storage_quit(struct map_session_data* sd, int flag)
else
storage_guild_storagesave(sd->status.account_id,sd->status.guild_id,1);
}
sd->state.storage_flag = 0;
stor->storage_status = 0;

View File

@ -91,13 +91,13 @@ void trade_traderequest(struct map_session_data *sd, struct map_session_data *ta
/**
* Reply to a trade-request.
* @param sd : player receiving the trade request answer
* @param type : answer code \n
* 0: Char is too far \n
* 1: Character does not exist \n
* 2: Trade failed \n
* 3: Accept \n
* 4: Cancel \n
* Weird enough, the client should only send 3/4 \n
* @param type : answer code
* 0: Char is too far
* 1: Character does not exist
* 2: Trade failed
* 3: Accept
* 4: Cancel
* Weird enough, the client should only send 3/4
* and the server is the one that can reply 0~2
*/
void trade_tradeack(struct map_session_data *sd, int type)
@ -168,7 +168,7 @@ void trade_tradeack(struct map_session_data *sd, int type)
/**
* Check here hacker for duplicate item in trade
* normal client refuse to have 2 same types of item (except equipment) in same trade window
* normal client authorise only no equiped item and only from inventory
* normal client authorise only no equipped item and only from inventory
* This function could end player connection if too much hack is detected
* @param sd : player to check
* @return -1:zeny hack, 0:all fine, 1:item hack

File diff suppressed because it is too large Load Diff

View File

@ -293,7 +293,7 @@ void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const ui
* Player setup a new shop
* @param sd : player opening the shop
* @param message : shop title
* @param data : itemlist data \n
* @param data : itemlist data
* data := {<index>.w <amount>.w <value>.l}[count]
* @param count : number of different items
* @return 0 If success, 1 - Cannot open (die, not state.prevend, trading), 2 - No cart, 3 - Count issue, 4 - Cart data isn't saved yet, 5 - No valid item found