Selaa lähdekoodia

Upd Documentation

Update some src documentation for doxygen
Fix typo in [hash:9cca188] in clif, making it uncompilable
lighta 11 vuotta sitten
vanhempi
commit
00e63be81c
8 muutettua tiedostoa jossa 653 lisäystä ja 512 poistoa
  1. 2 0
      src/map/clif.c
  2. 6 3
      src/map/status.c
  3. 192 118
      src/map/storage.c
  4. 48 29
      src/map/trade.c
  5. 335 331
      src/map/unit.c
  6. 8 7
      src/map/unit.h
  7. 59 21
      src/map/vending.c
  8. 3 3
      src/map/vending.h

+ 2 - 0
src/map/clif.c

@@ -1931,6 +1931,7 @@ void clif_scriptclear(struct map_session_data *sd, int npcid)
 	struct s_packet_db* info;
 	int16 len;
 	int cmd = 0;
+	int fd;
 
 	nullpo_retv(sd);
 
@@ -1938,6 +1939,7 @@ void clif_scriptclear(struct map_session_data *sd, int npcid)
 	if(!cmd) cmd = 0x8d6; //default
 	info = &packet_db[sd->packet_ver][cmd];
 	len = info->len;
+	fd = sd->fd;
 
 	WFIFOHEAD(fd, len);
 	WFIFOW(fd,0)=0x8d6;

+ 6 - 3
src/map/status.c

@@ -1412,7 +1412,9 @@ int status_damage(struct block_list *src,struct block_list *target,int64 dhp, in
 	}
 
 	// Always run NPC scripts for players last
-	if(target->type == BL_PC) {
+	//FIXME those ain't always run if a player die if he was resurect meanwhile
+	//cf SC_REBIRTH, SC_LIGHT_OF_REGENE, SC_KAIZEL, pc_dead...
+	if(target->type == BL_PC) { 
 		TBL_PC *sd = BL_CAST(BL_PC,target);
 		if( sd->bg_id ) {
 			struct battleground_data *bg;
@@ -1431,7 +1433,7 @@ int status_damage(struct block_list *src,struct block_list *target,int64 dhp, in
 * @param bl: Object to heal [PC|MOB|HOM|MER|ELEM]
 * @param hhp: How much HP to heal
 * @param hsp: How much SP to heal
-* @param flag:	Whether it's Forced(&1) or gives HP/SP(&2) heal effect
+* @param flag:	Whether it's Forced(&1) or gives HP/SP(&2) heal effect \n
 *		Forced healing overrides heal impedement statuses (Berserk)
 * @return hp+sp
 **/
@@ -1512,7 +1514,8 @@ int status_heal(struct block_list *bl,int64 hhp,int64 hsp, int flag)
 * @param target: Object to modify HP/SP
 * @param hp_rate: Percentage of HP to modify
 * @param sp_rate: Percentage of SP to modify
-* @param flag:	0: Heal target
+* @param flag: \n
+*		0: Heal target \n 
 *		2: Target must not die from subtraction
 * @return hp+sp through status_heal()
 **/

+ 192 - 118
src/map/storage.c

@@ -24,11 +24,15 @@
 #include <string.h>
 
 
-static DBMap* guild_storage_db; // int guild_id -> struct guild_storage*
+static DBMap* guild_storage_db; ///Databases of guild_storage : int guild_id -> struct guild_storage*
 
-/*==========================================
- * Sort items in the warehouse
- *------------------------------------------*/
+/**
+ * Storage item comparator (for qsort)
+ * sort by itemid and amount
+ * @param _i1 : item a
+ * @param _i2 : item b
+ * @return i1<=>i2
+ */
 static int storage_comp_item(const void *_i1, const void *_i2)
 {
 	struct item *i1 = (struct item *)_i1;
@@ -43,7 +47,12 @@ static int storage_comp_item(const void *_i1, const void *_i2)
 	return i1->nameid - i2->nameid;
 }
 
-//Sort item by storage_comp_item (nameid)
+/**
+ * Sort item by storage_comp_item (nameid)
+ * used when we open up our storage or guild_storage
+ * @param items : list of items to sort
+ * @param size : number of item in list
+ */
 static void storage_sortitem(struct item* items, unsigned int size)
 {
 	nullpo_retv(items);
@@ -54,22 +63,32 @@ static void storage_sortitem(struct item* items, unsigned int size)
 	}
 }
 
-/*==========================================
- * Init/Terminate
- *------------------------------------------*/
-int do_init_storage(void) // Called from map.c::do_init()
+/**
+ * Initiate storage module
+ * Called from map.c::do_init()
+ * @return 1
+ */
+int do_init_storage(void) // 
 {
 	guild_storage_db=idb_alloc(DB_OPT_RELEASE_DATA);
 	return 1;
 }
-void do_final_storage(void) // by [MC Cameri]
+
+/**
+ * Destroy storage module
+ * @author : [MC Cameri]
+ * Called from map.c::do_final()
+ */
+void do_final_storage(void)
 {
 	guild_storage_db->destroy(guild_storage_db,NULL);
 }
 
 /**
- * Parses storage and saves 'dirty' ones upon reconnect. [Skotlex]
+ * Parses storage and saves 'dirty' ones upon reconnect.
+ * @author [Skotlex]
  * @see DBApply
+ * @return 0
  */
 static int storage_reconnect_sub(DBKey key, DBData *data, va_list ap)
 {
@@ -80,17 +99,20 @@ static int storage_reconnect_sub(DBKey key, DBData *data, va_list ap)
 	return 0;
 }
 
-//Function to be invoked upon server reconnection to char. To save all 'dirty' storages [Skotlex]
+/**
+ * Function to be invoked upon server reconnection to char. To save all 'dirty' storages
+ * @author [Skotlex]
+ */
 void do_reconnect_storage(void)
 {
 	guild_storage_db->foreach(guild_storage_db, storage_reconnect_sub);
 }
 
-/*==========================================
- * Opens a storage. Returns:
- * 0 - success
- * 1 - fail
- *------------------------------------------*/
+/**
+ * Player attempt tp open his storage.
+ * @param sd : player
+ * @return  0:success, 1:fail
+ */
 int storage_storageopen(struct map_session_data *sd)
 {
 	nullpo_ret(sd);
@@ -111,8 +133,11 @@ int storage_storageopen(struct map_session_data *sd)
 	return 0;
 }
 
-/* helper function
- * checking if 2 item structure are identique
+/**
+ * check if 2 item a and b have same values
+ * @param a : item 1
+ * @param b : item 2
+ * @return 1:same, 0:are different
  */
 int compare_item(struct item *a, struct item *b)
 {
@@ -130,9 +155,13 @@ int compare_item(struct item *a, struct item *b)
 	return 0;
 }
 
-/*==========================================
- * Internal add-item function.
- *------------------------------------------*/
+/**
+ * Make a player add an item to his storage
+ * @param sd : player
+ * @param item_data : item to add
+ * @param amount : quantity of items
+ * @return 0:success, 1:failed
+ */
 static int storage_additem(struct map_session_data* sd, struct item* item_data, int amount)
 {
 	struct storage_data* stor = &sd->status.storage;
@@ -190,9 +219,13 @@ static int storage_additem(struct map_session_data* sd, struct item* item_data,
 	return 0;
 }
 
-/*==========================================
- * Internal del-item function
- *------------------------------------------*/
+/**
+ * Make a player delete an item from his storage
+ * @param sd : player
+ * @param n : idx on storage to remove the item from
+ * @param amount :number of item to remove
+ * @return 0:sucess, 1:fail
+ */
 int storage_delitem(struct map_session_data* sd, int n, int amount)
 {
 	if( sd->status.storage.items[n].nameid == 0 || sd->status.storage.items[n].amount < amount )
@@ -209,13 +242,13 @@ int storage_delitem(struct map_session_data* sd, int n, int amount)
 	return 0;
 }
 
-/*==========================================
+/**
  * Add an item to the storage from the inventory.
- * @index : inventory idx
- * return
- *	0 : fail
- *	1 : success
- *------------------------------------------*/
+ * @param sd : player
+ * @param index : inventory index to take the item from
+ * @param amount : number of item to take
+ * @return 0:fail, 1:success
+ */
 int storage_storageadd(struct map_session_data* sd, int index, int amount)
 {
 	nullpo_ret(sd);
@@ -242,13 +275,13 @@ int storage_storageadd(struct map_session_data* sd, int index, int amount)
 	return 1;
 }
 
-/*==========================================
+/**
  * Retrieve an item from the storage into inventory
- * @index : storage idx
- * return
- *	0 : fail
- *	1 : success
- *------------------------------------------*/
+ * @param sd : player
+ * @param index : storage index to take the item from
+ * @param amount : number of item to take
+ * @return 0:fail, 1:success
+ */
 int storage_storageget(struct map_session_data* sd, int index, int amount)
 {
 	int flag;
@@ -270,13 +303,13 @@ int storage_storageget(struct map_session_data* sd, int index, int amount)
 	return 1;
 }
 
-/*==========================================
+/**
  * Move an item from cart to storage.
- * @index : cart inventory index
- * return
- *	0 : fail
- *	1 : success
- *------------------------------------------*/
+ * @param sd : player
+ * @param index : cart index to take the item from
+ * @param amount : number of item to take
+ * @return 0:fail, 1:success
+ */
 int storage_storageaddfromcart(struct map_session_data* sd, int index, int amount)
 {
 	nullpo_ret(sd);
@@ -299,13 +332,13 @@ int storage_storageaddfromcart(struct map_session_data* sd, int index, int amoun
 	return 1;
 }
 
-/*==========================================
+/**
  * Get from Storage to the Cart inventory
- * @index : storage index
- * return
- *	0 : fail
- *	1 : success
- *------------------------------------------*/
+ * @param sd : player
+ * @param index : storage index to take the item from
+ * @param amount : number of item to take
+ * @return 0:fail, 1:success
+ */
 int storage_storagegettocart(struct map_session_data* sd, int index, int amount)
 {
 	short flag;
@@ -331,9 +364,11 @@ int storage_storagegettocart(struct map_session_data* sd, int index, int amount)
 }
 
 
-/*==========================================
- * Modified By Valaris to save upon closing [massdriller]
- *------------------------------------------*/
+/**
+ * Make player close his storage
+ * @author : [massdriller] / modified by [Valaris]
+ * @param sd : player
+ */
 void storage_storageclose(struct map_session_data* sd)
 {
 	nullpo_retv(sd);
@@ -346,9 +381,14 @@ void storage_storageclose(struct map_session_data* sd)
 	sd->state.storage_flag = 0;
 }
 
-/*==========================================
- * When quitting the game.
- *------------------------------------------*/
+/**
+ * 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
+ *	2(x): Character is changing map-servers 
+ */
 void storage_storage_quit(struct map_session_data* sd, int flag)
 {
 	nullpo_retv(sd);
@@ -360,7 +400,11 @@ void storage_storage_quit(struct map_session_data* sd, int flag)
 }
 
 /**
+ * Create a guild_storage stucture and add it into the db
  * @see DBCreateData
+ * @param key
+ * @param args
+ * @return 
  */
 static DBData create_guildstorage(DBKey key, va_list args)
 {
@@ -370,6 +414,12 @@ static DBData create_guildstorage(DBKey key, va_list args)
 	return db_ptr2data(gs);
 }
 
+/**
+ * Retrieve the guild_storage of a guild
+ * will create a new storage if none found for the guild
+ * @param guild_id : id of the guild
+ * @return guild_storage
+ */
 struct guild_storage *guild2storage(int guild_id)
 {
 	struct guild_storage *gs = NULL;
@@ -378,25 +428,33 @@ struct guild_storage *guild2storage(int guild_id)
 	return gs;
 }
 
-//For just locating a storage without creating one. [Skotlex]
+/**
+ * See if the guild_storage exist in db and fetch it if it,s the case
+ * @author : [Skotlex]
+ * @param guild_id : guild_id to search the storage
+ * @return guild_storage or NULL
+ */
 struct guild_storage *guild2storage2(int guild_id)
 {
 	return (struct guild_storage*)idb_get(guild_storage_db,guild_id);
 }
 
+/**
+ * Delete a guild_storage and remove it from db
+ * @param guild_id : guild to remove the storage from
+ * @return 0
+ */
 int guild_storage_delete(int guild_id)
 {
 	idb_remove(guild_storage_db,guild_id);
 	return 0;
 }
 
-/*==========================================
-* Attempt to open guild storage for sd
-* return
-* 	0 : success (open or req to create a new one)
-* 	1 : fail
-*	2 : no guild for sd
- *------------------------------------------*/
+/**
+ * Attempt to open guild storage for player
+ * @param sd : player
+ * @return * 	0 : success, 1 : fail, 2 : no guild found
+ */
 int storage_guild_storageopen(struct map_session_data* sd)
 {
 	struct guild_storage *gstor;
@@ -432,12 +490,14 @@ int storage_guild_storageopen(struct map_session_data* sd)
 	return 0;
 }
 
-/*==========================================
-* Attempt to add an item in guild storage, then refresh it
-* return
-* 	0 : success
-* 	1 : fail
- *------------------------------------------*/
+/**
+ * Attempt to add an item in guild storage, then refresh it
+ * @param sd : player attempting to open the guild_storage
+ * @param stor : guild_storage
+ * @param item_data : item to add
+ * @param amount : number of item to add
+ * @return 0 : success, 1 : fail
+ */
 int guild_storage_additem(struct map_session_data* sd, struct guild_storage* stor, struct item* item_data, int amount)
 {
 	struct item_data *data;
@@ -495,12 +555,14 @@ int guild_storage_additem(struct map_session_data* sd, struct guild_storage* sto
 	return 0;
 }
 
-/*==========================================
-* Attempt to delete an item in guild storage, then refresh it
-* return
-* 	0 : success
-* 	1 : fail
- *------------------------------------------*/
+/**
+ * Attempt to delete an item in guild storage, then refresh it
+ * @param sd : player
+ * @param stor : guild_storage
+ * @param n : index of item in guild storage
+ * @param amount : number of item to delete
+ * @return 0 : success, 1 : fail
+ */
 int guild_storage_delitem(struct map_session_data* sd, struct guild_storage* stor, int n, int amount)
 {
 	nullpo_retr(1, sd);
@@ -520,13 +582,12 @@ int guild_storage_delitem(struct map_session_data* sd, struct guild_storage* sto
 	return 0;
 }
 
-/*==========================================
-* Attempt to add an item in guild storage from inventory, then refresh it
-* @index : inventory idx
-* return
-* 	0 : fail
-* 	1 : succes
- *------------------------------------------*/
+/**
+ * Attempt to add an item in guild storage from inventory, then refresh it
+ * @param sd : player
+ * @param amount : number of item to delete
+ * @return 1:success, 0:fail
+ */
 int storage_guild_storageadd(struct map_session_data* sd, int index, int amount)
 {
 	struct guild_storage *stor;
@@ -561,13 +622,13 @@ int storage_guild_storageadd(struct map_session_data* sd, int index, int amount)
 	return 1;
 }
 
-/*==========================================
-* Attempt to retrieve an item from guild storage to inventory, then refresh it
-* @index : storage idx
-* return
-* 	0 : fail
-* 	1 : succes
- *------------------------------------------*/
+/**
+ * Attempt to retrieve an item from guild storage to inventory, then refresh it
+ * @param sd : player
+ * @param index : index of item in storage
+ * @param amount : number of item to get
+ * @return 1:success, 0:fail
+ */
 int storage_guild_storageget(struct map_session_data* sd, int index, int amount)
 {
 	struct guild_storage *stor;
@@ -595,20 +656,22 @@ int storage_guild_storageget(struct map_session_data* sd, int index, int amount)
 
 	if((flag = pc_additem(sd,&stor->items[index],amount,LOG_TYPE_GSTORAGE)) == 0)
 		guild_storage_delitem(sd,stor,index,amount);
-	else //inform fail
+	else {//inform fail
 		clif_additem(sd,0,0,flag);
+		return 0;
+	}
 //	log_fromstorage(sd, index, 1);
 
-	return 0;
+	return 1;
 }
 
-/*==========================================
-* Attempt to add an item in guild storage from cart, then refresh it
-* @index : cart inventory idx
-* return
-* 	0 : fail
-* 	1 : succes
- *------------------------------------------*/
+/**
+ * Attempt to add an item in guild storage from cart, then refresh it
+ * @param sd : player
+ * @param index : index of item in cart
+ * @param amount : number of item to transfer
+ * @return 1:fail, 0:success
+ */
 int storage_guild_storageaddfromcart(struct map_session_data* sd, int index, int amount)
 {
 	struct guild_storage *stor;
@@ -634,13 +697,13 @@ int storage_guild_storageaddfromcart(struct map_session_data* sd, int index, int
 	return 1;
 }
 
-/*==========================================
-* Attempt to retrieve an item from guild storage to cart, then refresh it
-* @index : storage idx
-* return
-* 	0 : fail
-* 	1 : succes
- *------------------------------------------*/
+/**
+ * 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
+ * @return 1:fail, 0:success
+ */
 int storage_guild_storagegettocart(struct map_session_data* sd, int index, int amount)
 {
 	short flag;
@@ -666,17 +729,19 @@ int storage_guild_storagegettocart(struct map_session_data* sd, int index, int a
 	else {
 		clif_dropitem(sd,index,0);
 		clif_cart_additem_ack(sd,(flag==1)?ADDITEM_TO_CART_FAIL_WEIGHT:ADDITEM_TO_CART_FAIL_COUNT);
+		return 0;
 	}
 
 	return 1;
 }
 
-/*==========================================
-* Request to save guild storage
-* return
-* 	0 : fail (no storage)
-* 	1 : succes
- *------------------------------------------*/
+/**
+ * Request to save guild storage
+ * @param account_id : account requesting the save
+ * @param guild_id : guild to take the guild_storage
+ * @param flag : ?
+ * @return 0 : fail (no storage), 1 : success (requested)
+ */
 int storage_guild_storagesave(int account_id, int guild_id, int flag)
 {
 	struct guild_storage *stor = guild2storage2(guild_id);
@@ -692,12 +757,11 @@ int storage_guild_storagesave(int account_id, int guild_id, int flag)
 	return 0;
 }
 
-/*==========================================
-* ACK save of guild storage
-* return
-* 	0 : fail (no storage)
-* 	1 : succes
- *------------------------------------------*/
+/**
+ * ACK save of guild storage
+ * @param guild_id : guild to use the storage
+ * @return 0 : fail (no storage), 1 : succes
+ */
 int storage_guild_storagesaved(int guild_id)
 {
 	struct guild_storage *stor;
@@ -712,7 +776,11 @@ int storage_guild_storagesaved(int guild_id)
 	return 0;
 }
 
-//Close storage for sd and save it
+/**
+ * Close storage for player then save it
+ * @param sd : player
+ * @return 0
+ */
 int storage_guild_storageclose(struct map_session_data* sd)
 {
 	struct guild_storage *stor;
@@ -734,6 +802,12 @@ int storage_guild_storageclose(struct map_session_data* sd)
 	return 0;
 }
 
+/**
+ * Close storage for player then save it
+ * @param sd
+ * @param flag
+ * @return 
+ */
 int storage_guild_storage_quit(struct map_session_data* sd, int flag)
 {
 	struct guild_storage *stor;

+ 48 - 29
src/map/trade.c

@@ -20,13 +20,13 @@
 #include <stdio.h>
 #include <string.h>
 
+#define TRADE_DISTANCE 2 ///Max distance from traders to enable a trade to take place.
 
-//Max distance from traders to enable a trade to take place.
-#define TRADE_DISTANCE 2
-
-/*==========================================
- * Initiates a trade request.
- *------------------------------------------*/
+/**
+ * Player initiates a trade request.
+ * @param sd : player requesting the trade
+ * @param target_sd : player requested
+ */
 void trade_traderequest(struct map_session_data *sd, struct map_session_data *target_sd)
 {
 	nullpo_retv(sd);
@@ -88,17 +88,19 @@ void trade_traderequest(struct map_session_data *sd, struct map_session_data *ta
 	clif_traderequest(target_sd, sd->status.name);
 }
 
-/*==========================================
+
+/**
  * Reply to a trade-request.
- * Type values:
- * 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
+ * @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
  * and the server is the one that can reply 0~2
- *------------------------------------------*/
+ */
 void trade_tradeack(struct map_session_data *sd, int type)
 {
 	struct map_session_data *tsd;
@@ -165,11 +167,14 @@ void trade_tradeack(struct map_session_data *sd, int type)
 	clif_tradestart(sd, 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
- *------------------------------------------*/
+ * 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
+ */
 int impossible_trade_check(struct map_session_data *sd)
 {
 	struct item inventory[MAX_INVENTORY];
@@ -229,9 +234,12 @@ int impossible_trade_check(struct map_session_data *sd)
 	return 0;
 }
 
-/*==========================================
+/**
  * Checks if trade is possible (against zeny limits, inventory limits, etc)
- *------------------------------------------*/
+ * @param sd : player 1 trading
+ * @param tsd : player 2 trading
+ * @return 0:error, 1:success
+ */
 int trade_check(struct map_session_data *sd, struct map_session_data *tsd)
 {
 	struct item inventory[MAX_INVENTORY];
@@ -316,9 +324,12 @@ int trade_check(struct map_session_data *sd, struct map_session_data *tsd)
 	return 1;
 }
 
-/*==========================================
+/**
  * Adds an item/qty to the trade window
- *------------------------------------------*/
+ * @param sd : Player requesting to add stuff to the trade
+ * @param index : index of item in inventory
+ * @param amount : amount of item to add from index
+ */
 void trade_tradeadditem(struct map_session_data *sd, short index, short amount)
 {
 	struct map_session_data *target_sd;
@@ -409,9 +420,13 @@ void trade_tradeadditem(struct map_session_data *sd, short index, short amount)
 	clif_tradeadditem(sd, target_sd, index+2, amount);
 }
 
-/*==========================================
+/**
  * Adds the specified amount of zeny to the trade window
- *------------------------------------------*/
+ * This function will check if the player have enough money to do so
+ * And if the target player have enough space for that money
+ * @param sd : Player who's adding zeny
+ * @param amount : zeny amount
+ */
 void trade_tradeaddzeny(struct map_session_data* sd, int amount)
 {
 	struct map_session_data* target_sd;
@@ -436,9 +451,10 @@ void trade_tradeaddzeny(struct map_session_data* sd, int amount)
 	clif_tradeadditem(sd, target_sd, 0, amount);
 }
 
-/*==========================================
+/**
  * 'Ok' button on the trade window is pressed.
- *------------------------------------------*/
+ * @param sd : Player that pressed the button
+ */
 void trade_tradeok(struct map_session_data *sd)
 {
 	struct map_session_data *target_sd;
@@ -456,9 +472,10 @@ void trade_tradeok(struct map_session_data *sd)
 	clif_tradedeal_lock(target_sd, 1);
 }
 
-/*==========================================
+/**
  * 'Cancel' is pressed. (or trade was force-cancelled by the code)
- *------------------------------------------*/
+ * @param sd : Player that pressed the button
+ */
 void trade_tradecancel(struct map_session_data *sd)
 {
 	struct map_session_data *target_sd;
@@ -515,9 +532,11 @@ void trade_tradecancel(struct map_session_data *sd)
 	clif_tradecancelled(target_sd);
 }
 
-/*==========================================
+/**
+ * Execute the trade
  * lock sd and tsd trade data, execute the trade, clear, then save players
- *------------------------------------------*/
+ * @param sd : Player that has click on trade button
+ */
 void trade_tradecommit(struct map_session_data *sd)
 {
 	struct map_session_data *tsd;

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 335 - 331
src/map/unit.c


+ 8 - 7
src/map/unit.h

@@ -14,9 +14,12 @@ struct map_session_data;
 #include "path.h" // struct walkpath_data
 #include "skill.h" // struct skill_timerskill, struct skill_unit_group, struct skill_unit_group_tickset
 
+extern const short dirx[8]; ///lookup to know where will move to x according dir
+extern const short diry[8]; ///lookup to know where will move to y according dir
+
 struct unit_data {
-	struct block_list *bl;
-	struct walkpath_data walkpath;
+	struct block_list *bl; ///link to owner object BL_CHAR (BL_PC|BL_HOM|BL_PET|BL_ELE|BL_MER)
+	struct walkpath_data walkpath; 
 	struct skill_timerskill *skilltimerskill[MAX_SKILLTIMERSKILL];
 	struct skill_unit_group *skillunit[MAX_SKILLUNITGROUP];
 	struct skill_unit_group_tickset skillunittick[MAX_SKILLUNITGROUPTICKSET];
@@ -78,6 +81,9 @@ int unit_calc_pos(struct block_list *bl, int tx, int ty, uint8 dir);
 int unit_delay_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data);
 int unit_delay_walktobl_timer(int tid, unsigned int tick, int id, intptr_t data);
 
+// Ranger
+int unit_wugdash(struct block_list *bl, struct map_session_data *sd);
+
 // Causes the target object to stop moving.
 int unit_stop_walking(struct block_list *bl,int type);
 int unit_can_move(struct block_list *bl);
@@ -130,10 +136,5 @@ int unit_changeviewsize(struct block_list *bl,short size);
 int do_init_unit(void);
 int do_final_unit(void);
 
-// Ranger
-int unit_wugdash(struct block_list *bl, struct map_session_data *sd);
-
-extern const short dirx[8];
-extern const short diry[8];
 
 #endif /* _UNIT_H_ */

+ 59 - 21
src/map/vending.c

@@ -20,21 +20,29 @@
 #include <stdio.h>
 #include <string.h>
 
-static int vending_nextid = 0;
-static DBMap *vending_db;
+static int vending_nextid = 0; ///Vending_id counter
+static DBMap *vending_db; ///Db holder the vender : charid -> map_session_data
 
+/**
+ * Lookup to get the vending_db outside module
+ * @return the vending_db
+ */
 DBMap * vending_getdb(){
 	return vending_db;
 }
-/// Returns an unique vending shop id.
-static int vending_getuid(void)
-{
+
+/**
+ * Create an unique vending shop id.
+ * @return the next vending_id
+ */
+static int vending_getuid(void){
 	return ++vending_nextid;
 }
 
-/*==========================================
- * Close shop
- *------------------------------------------*/
+/**
+ * Make a player close his shop
+ * @param sd : player session
+ */
 void vending_closevending(struct map_session_data* sd)
 {
 	nullpo_retv(sd);
@@ -46,9 +54,11 @@ void vending_closevending(struct map_session_data* sd)
 	}
 }
 
-/*==========================================
- * Request a shop's item list
- *------------------------------------------*/
+/**
+ * Player request a shop's item list (a player shop)
+ * @param sd : player requestion the list
+ * @param id : vender account id (gid)
+ */
 void vending_vendinglistreq(struct map_session_data* sd, int id)
 {
 	struct map_session_data* vsd;
@@ -70,9 +80,15 @@ void vending_vendinglistreq(struct map_session_data* sd, int id)
 	clif_vendinglist(sd, id, vsd->vending);
 }
 
-/*==========================================
+/**
  * Purchase item(s) from a shop
- *------------------------------------------*/
+ * @param sd : buyer player session
+ * @param aid : account id of vender
+ * @param uid : shop unique id
+ * @param data : items data who would like to purchase \n
+ *	data := {<index>.w <amount>.w }[count]
+ * @param count : number of different items he's trying to buy
+ */
 void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const uint8* data, int count)
 {
 	int i, j, cursor, w, new_ = 0, blank, vend_list[MAX_VENDING];
@@ -226,10 +242,14 @@ void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const ui
 	}
 }
 
-/*==========================================
- * Open shop
- * data := {<index>.w <amount>.w <value>.l}[count]
- *------------------------------------------*/
+/**
+ * Player setup a new shop
+ * @param sd : player opening the shop
+ * @param message : shop title
+ * @param data : itemlist data \n
+ *	data := {<index>.w <amount>.w <value>.l}[count]
+ * @param count : number of different items
+ */
 void vending_openvending(struct map_session_data* sd, const char* message, const uint8* data, int count) {
 	int i, j;
 	int vending_skill_lvl;
@@ -297,8 +317,12 @@ void vending_openvending(struct map_session_data* sd, const char* message, const
 	idb_put(vending_db, sd->status.char_id, sd);
 }
 
-
-/// Checks if an item is being sold in given player's vending.
+/**
+ * Checks if an item is being sold in given player's vending.
+ * @param sd : vender session (player)
+ * @param nameid : item id
+ * @return 0:not selling it, 1: yes
+ */
 bool vending_search(struct map_session_data* sd, unsigned short nameid) {
 	int i;
 
@@ -315,8 +339,13 @@ bool vending_search(struct map_session_data* sd, unsigned short nameid) {
 }
 
 
-/// Searches for all items in a vending, that match given ids, price and possible cards.
-/// @return Whether or not the search should be continued.
+
+/**
+ * Searches for all items in a vending, that match given ids, price and possible cards.
+ * @param sd : The vender session to search into
+ * @param s : parameter of the search (see s_search_store_search)
+ * @return Whether or not the search should be continued.
+ */
 bool vending_searchall(struct map_session_data* sd, const struct s_search_store_search* s) {
 	int i, c, slot;
 	unsigned int idx, cidx;
@@ -367,10 +396,19 @@ bool vending_searchall(struct map_session_data* sd, const struct s_search_store_
 
 	return true;
 }
+
+/**
+ * Initialise the vending module
+ * called in map::do_init
+ */
 void do_final_vending(void) {
 	db_destroy(vending_db);
 }
 
+/**
+ * Destory the vending module
+ * called in map::do_final
+ */
 void do_init_vending(void) {
 	vending_db = idb_alloc(DB_OPT_BASE);
 	vending_nextid = 0;

+ 3 - 3
src/map/vending.h

@@ -10,9 +10,9 @@ struct map_session_data;
 struct s_search_store_search;
 
 struct s_vending {
-	short index; //cart index (return item data)
-	short amount; //amout of the item for vending
-	unsigned int value; //at wich price
+	short index; /// cart index (return item data)
+	short amount; ///amout of the item for vending
+	unsigned int value; ///at wich price
 };
 
 DBMap * vending_getdb();

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä