ソースを参照

-Fix bugreport:7904 (clif warning for cashshop #else date)
-Fix bugreport:7905 (status warning for homun str calc, float to int)
-Fix bugreport:7884 (SL_STIN, SL_STUN now support casting by non player)
-Add few doc and C++ support

lighta 11 年 前
コミット
f6e76387c7
10 ファイル変更154 行追加49 行削除
  1. 1 0
      src/map/channel.c
  2. 5 5
      src/map/chat.c
  3. 9 2
      src/map/chat.h
  4. 1 1
      src/map/clif.c
  5. 30 0
      src/map/date.c
  6. 8 0
      src/map/date.h
  7. 56 8
      src/map/duel.c
  8. 11 3
      src/map/duel.h
  9. 32 29
      src/map/skill.c
  10. 1 1
      src/map/status.c

+ 1 - 0
src/map/channel.c

@@ -20,6 +20,7 @@
 static DBMap* channel_db; // channels
 DBMap* channel_get_db(void){ return channel_db; }
 
+
 struct chan_banentry {
 	int char_id;
 	char char_name[NAME_LENGTH];

+ 5 - 5
src/map/chat.c

@@ -156,13 +156,13 @@ int chat_joinchat(struct map_session_data* sd, int chatid, const char* pass)
 
 	pc_setchatid(sd,cd->bl.id);
 
-    clif_joinchatok(sd, cd); //To the person who newly joined the list of all
-    clif_addchat(cd, sd); //Reports To the person who already in the chat
-    clif_dispchat(cd, 0); //Reported number of changes to the people around
+	clif_joinchatok(sd, cd); //To the person who newly joined the list of all
+	clif_addchat(cd, sd); //Reports To the person who already in the chat
+	clif_dispchat(cd, 0); //Reported number of changes to the people around
 
-    chat_triggerevent(cd); //Event
+	chat_triggerevent(cd); //Event
 
-    return 0;
+	return 0;
 }
 
 

+ 9 - 2
src/map/chat.h

@@ -5,10 +5,14 @@
 #define _CHAT_H_
 
 #include "map.h" // struct block_list, CHATROOM_TITLE_SIZE
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
 struct map_session_data;
 struct chat_data;
 
-
 struct chat_data {
 	struct block_list bl;            // data for this map object
 	char title[CHATROOM_TITLE_SIZE]; // room title 
@@ -26,7 +30,6 @@ struct chat_data {
 	DBMap* kick_list;				//DBMap of users who were kicked from this chat
 };
 
-
 int chat_createpcchat(struct map_session_data* sd, const char* title, const char* pass, int limit, bool pub);
 int chat_joinchat(struct map_session_data* sd, int chatid, const char* pass);
 int chat_leavechat(struct map_session_data* sd, bool kicked);
@@ -40,4 +43,8 @@ int chat_enableevent(struct chat_data* cd);
 int chat_disableevent(struct chat_data* cd);
 int chat_npckickall(struct chat_data* cd);
 
+#ifdef	__cplusplus
+}
+#endif
+
 #endif /* _CHAT_H_ */

+ 1 - 1
src/map/clif.c

@@ -14563,7 +14563,7 @@ void clif_parse_cashshop_buy(int fd, struct map_session_data *sd){
 		}
 	#if PACKETVER < 20130000
 		fail = npc_cashshop_buylist(sd,points,count,item_list);
-	#else PACKETVER >= 20130000
+	#elif PACKETVER >= 20130000
 		cashshop_buylist( sd, points, count, item_list);
 	#endif
 #endif

+ 30 - 0
src/map/date.c

@@ -4,6 +4,9 @@
 #include "date.h"
 #include <time.h>
 
+/*
+ * Get the current year
+ */
 int date_get_year(void)
 {
 	time_t t;
@@ -12,6 +15,10 @@ int date_get_year(void)
 	lt = localtime(&t);
 	return lt->tm_year+1900;
 }
+
+/*
+ * Get the current month
+ */
 int date_get_month(void)
 {
 	time_t t;
@@ -20,6 +27,10 @@ int date_get_month(void)
 	lt = localtime(&t);
 	return lt->tm_mon+1;
 }
+
+/*
+ * Get the current day (days of the month)
+ */
 int date_get_day(void)
 {
 	time_t t;
@@ -28,6 +39,10 @@ int date_get_day(void)
 	lt = localtime(&t);
 	return lt->tm_mday;
 }
+
+/*
+ * Get the current hours
+ */
 int date_get_hour(void)
 {
 	time_t t;
@@ -37,6 +52,9 @@ int date_get_hour(void)
 	return lt->tm_hour;
 }
 
+/*
+ * Get the current minutes
+ */
 int date_get_min(void)
 {
 	time_t t;
@@ -46,6 +64,9 @@ int date_get_min(void)
 	return lt->tm_min;
 }
 
+/*
+ * Get the current seconds
+ */
 int date_get_sec(void)
 {
 	time_t t;
@@ -55,16 +76,25 @@ int date_get_sec(void)
 	return lt->tm_sec;
 }
 
+/*
+ * Does this day is a day of the Sun, (for SG)
+ */
 int is_day_of_sun(void)
 {
 	return date_get_day()%2 == 0;
 }
 
+/*
+ * Does this day is a day of the Moon, (for SG)
+ */
 int is_day_of_moon(void)
 {
 	return date_get_day()%2 == 1;
 }
 
+/*
+ * Does this day is a day of the Star, (for SG)
+ */
 int is_day_of_star(void)
 {
 	return date_get_day()%5 == 0;

+ 8 - 0
src/map/date.h

@@ -4,6 +4,10 @@
 #ifndef _DATE_H_
 #define _DATE_H_
 
+#ifdef	__cplusplus
+extern "C" {
+#endif
+    
 int date_get_year(void);
 int date_get_month(void);
 int date_get_day(void);
@@ -15,4 +19,8 @@ int is_day_of_sun(void);
 int is_day_of_moon(void);
 int is_day_of_star(void);
 
+#ifdef	__cplusplus
+}
+#endif
+
 #endif /* _DATE_H_ */

+ 56 - 8
src/map/duel.c

@@ -1,5 +1,6 @@
 // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
 // For more information, see LICENCE in the main folder
+// Duel organizing functions [LuzZza]
 
 #include "../common/cbasetypes.h"
 
@@ -13,12 +14,13 @@
 #include <string.h>
 #include <time.h>
 
-struct duel duel_list[MAX_DUEL];
-int duel_count = 0;
+//global var (extern)
+struct duel duel_list[MAX_DUEL]; //list of current duel
+int duel_count = 0; //number of duel active
 
-/*==========================================
- * Duel organizing functions [LuzZza]
- *------------------------------------------*/
+/*
+ * Save the current time of the duel in PC_LAST_DUEL_TIME
+ */
 void duel_savetime(struct map_session_data* sd)
 {
 	time_t timer;
@@ -30,6 +32,9 @@ void duel_savetime(struct map_session_data* sd)
 	pc_setglobalreg(sd, "PC_LAST_DUEL_TIME", t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min);
 }
 
+/*
+ * Check if the time elapsed between last duel is enough to launch another.
+ */
 int duel_checktime(struct map_session_data* sd)
 {
 	int diff;
@@ -37,12 +42,16 @@ int duel_checktime(struct map_session_data* sd)
 	struct tm *t;
 
 	time(&timer);
-    t = localtime(&timer);
+	t = localtime(&timer);
 
 	diff = t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min - pc_readglobalreg(sd, "PC_LAST_DUEL_TIME");
 
 	return !(diff >= 0 && diff < battle_config.duel_time_interval);
 }
+
+/*
+ * Display opponents name of sd
+ */
 static int duel_showinfo_sub(struct map_session_data* sd, va_list va)
 {
 	struct map_session_data *ssd = va_arg(va, struct map_session_data*);
@@ -56,6 +65,10 @@ static int duel_showinfo_sub(struct map_session_data* sd, va_list va)
 	return 1;
 }
 
+/*
+ * Display duel infos,
+ * Number of duely...
+ */
 void duel_showinfo(const unsigned int did, struct map_session_data* sd)
 {
 	int p=0;
@@ -77,6 +90,9 @@ void duel_showinfo(const unsigned int did, struct map_session_data* sd)
 	map_foreachpc(duel_showinfo_sub, sd, &p);
 }
 
+/*
+ * Create a new duel for sd
+ */
 int duel_create(struct map_session_data* sd, const unsigned int maxpl)
 {
 	int i=1;
@@ -100,6 +116,12 @@ int duel_create(struct map_session_data* sd, const unsigned int maxpl)
 	return i;
 }
 
+/*
+ * Invite opponent into the duel.
+ * @did = duel id
+ * @sd = inviting player
+ * @target_sd = invited player
+ */
 void duel_invite(const unsigned int did, struct map_session_data* sd, struct map_session_data* target_sd)
 {
 	char output[256];
@@ -116,6 +138,11 @@ void duel_invite(const unsigned int did, struct map_session_data* sd, struct map
 	clif_broadcast((struct block_list *)target_sd, output, strlen(output)+1, 0x10, SELF);
 }
 
+/*
+ * Sub function to loop trough all duely to remove invite for sd
+ * @sd = leaving player
+ * @va = list(only contain duel_id atm)
+ */
 static int duel_leave_sub(struct map_session_data* sd, va_list va)
 {
 	int did = va_arg(va, int);
@@ -124,6 +151,11 @@ static int duel_leave_sub(struct map_session_data* sd, va_list va)
 	return 0;
 }
 
+/*
+ * Make a player leave a duel
+ * @did = duel id
+ * @sd = leaving player
+ */
 void duel_leave(const unsigned int did, struct map_session_data* sd)
 {
 	char output[256];
@@ -145,6 +177,11 @@ void duel_leave(const unsigned int did, struct map_session_data* sd)
 	clif_maptypeproperty2(&sd->bl,SELF);
 }
 
+/*
+ * Make a player accept a duel
+ * @did = duel id
+ * @sd = player accepting duel
+ */
 void duel_accept(const unsigned int did, struct map_session_data* sd)
 {
 	char output[256];
@@ -163,6 +200,11 @@ void duel_accept(const unsigned int did, struct map_session_data* sd)
 	//clif_misceffect2(&sd->bl, 159);
 }
 
+/*
+ * Make a player decline a duel
+ * @did = duel id
+ * @sd = player refusing duel
+ */
 void duel_reject(const unsigned int did, struct map_session_data* sd)
 {
 	char output[256];
@@ -175,11 +217,17 @@ void duel_reject(const unsigned int did, struct map_session_data* sd)
 	sd->duel_invite = 0;
 }
 
+/*
+ * Destructor of duel module
+ * Put cleanup code here before server end
+ */
 void do_final_duel(void)
 {
 }
 
-void do_init_duel(void)
-{
+/*
+ * Initialisator of duel module
+ */
+void do_init_duel(void) {
 	memset(&duel_list[0], 0, sizeof(duel_list));
 }

+ 11 - 3
src/map/duel.h

@@ -4,15 +4,19 @@
 #ifndef _DUEL_H_
 #define _DUEL_H_
 
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
 struct duel {
 	int members_count;
 	int invites_count;
 	int max_players_limit;
 };
 
-#define MAX_DUEL 1024
-extern struct duel duel_list[MAX_DUEL];
-extern int duel_count;
+#define MAX_DUEL 1024 //max number of duels on server
+extern struct duel duel_list[MAX_DUEL]; //list of current duel
+extern int duel_count; //current number of duel on server
 
 //Duel functions // [LuzZza]
 int duel_create(struct map_session_data* sd, const unsigned int maxpl);
@@ -26,4 +30,8 @@ int duel_checktime(struct map_session_data* sd);
 void do_init_duel(void);
 void do_final_duel(void);
 
+#ifdef	__cplusplus
+}
+#endif
+
 #endif /* _DUEL_H_ */

+ 32 - 29
src/map/skill.c

@@ -2342,7 +2342,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
 {
 	struct Damage dmg;
 	struct status_data *sstatus, *tstatus;
-	struct status_change *sc;
+	struct status_change *tsc;
 	struct map_session_data *sd, *tsd;
 	int type,damage,rdamage=0;
 	int8 rmdamage=0;//magic reflected
@@ -2369,14 +2369,14 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
 
 	sstatus = status_get_status_data(src);
 	tstatus = status_get_status_data(bl);
-	sc= status_get_sc(bl);
-	if (sc && !sc->count) sc = NULL; //Don't need it.
+	tsc= status_get_sc(bl); 
+	if (tsc && !tsc->count) tsc = NULL; //Don't need it.
 
 	// Is this check really needed? FrostNova won't hurt you if you step right where the caster is?
 	if(skill_id == WZ_FROSTNOVA && dsrc->x == bl->x && dsrc->y == bl->y)
 		return 0;
 	 //Trick Dead protects you from damage, but not from buffs and the like, hence it's placed here.
-	if (sc && sc->data[SC_TRICKDEAD])
+	if (tsc && tsc->data[SC_TRICKDEAD])
 		return 0;
 	
 	dmg = battle_calc_attack(attack_type,src,bl,skill_id,skill_lv,flag&0xFFF);
@@ -2408,22 +2408,22 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
 			dsrc = tbl;
 			sd = BL_CAST(BL_PC, src);
 			tsd = BL_CAST(BL_PC, bl);
-			sc = status_get_sc(bl);
-			if (sc && !sc->count)
-				sc = NULL; //Don't need it.
+			tsc = status_get_sc(bl);
+			if (tsc && !tsc->count)
+				tsc = NULL; //Don't need it.
 			/* bugreport:2564 flag&2 disables double casting trigger */
 			flag |= 2;
 
 			//Spirit of Wizard blocks Kaite's reflection
-			if( type == 2 && sc && sc->data[SC_SPIRIT] && sc->data[SC_SPIRIT]->val2 == SL_WIZARD )
+			if( type == 2 && tsc && tsc->data[SC_SPIRIT] && tsc->data[SC_SPIRIT]->val2 == SL_WIZARD )
 			{	//Consume one Fragment per hit of the casted skill? [Skotlex]
-			  	type = tsd?pc_search_inventory (tsd, 7321):0;
+				type = tsd?pc_search_inventory (tsd, 7321):0;
 				if (type >= 0) {
 					if ( tsd ) pc_delitem(tsd, type, 1, 0, 1, LOG_TYPE_CONSUME);
 					dmg.damage = dmg.damage2 = 0;
 					dmg.dmg_lv = ATK_MISS;
-					sc->data[SC_SPIRIT]->val3 = skill_id;
-					sc->data[SC_SPIRIT]->val4 = dsrc->id;
+					tsc->data[SC_SPIRIT]->val3 = skill_id;
+					tsc->data[SC_SPIRIT]->val4 = dsrc->id;
 				}
 			} else if( type != 2 ) /* Kaite bypasses */
 				additional_effects = false;
@@ -2444,7 +2444,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
 
 				dmg.damage = battle_attr_fix(bl, bl, dmg.damage, s_ele, status_get_element(bl), status_get_element_level(bl));
 
-				if( sc && sc->data[SC_ENERGYCOAT] ) {
+				if( tsc && tsc->data[SC_ENERGYCOAT] ) {
 					struct status_data *status = status_get_status_data(bl);
 					int per = 100*status->sp / status->max_sp -1; //100% should be counted as the 80~99% interval
 					per /=20; //Uses 20% SP intervals.
@@ -2457,11 +2457,11 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
 		}
 		#endif
 		}
-		if(sc && sc->data[SC_MAGICROD] && src == dsrc) {
+		if(tsc && tsc->data[SC_MAGICROD] && src == dsrc) {
 			int sp = skill_get_sp(skill_id,skill_lv);
 			dmg.damage = dmg.damage2 = 0;
 			dmg.dmg_lv = ATK_MISS; //This will prevent skill additional effect from taking effect. [Skotlex]
-			sp = sp * sc->data[SC_MAGICROD]->val2 / 100;
+			sp = sp * tsc->data[SC_MAGICROD]->val2 / 100;
 			if(skill_id == WZ_WATERBALL && skill_lv > 1)
 				sp = sp/((skill_lv|1)*(skill_lv|1)); //Estimate SP cost of a single water-ball
 			status_heal(bl, 0, sp, 2);
@@ -2477,10 +2477,10 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
 
 	if( damage > 0 && (( dmg.flag&BF_WEAPON && src != bl && ( src == dsrc || ( dsrc->type == BL_SKILL &&
 		( skill_id == SG_SUN_WARM || skill_id == SG_MOON_WARM || skill_id == SG_STAR_WARM ) ) ))
-		|| ((sc && sc->data[SC_REFLECTDAMAGE]) && !(dmg.flag&(BF_MAGIC|BF_LONG)) && !(skill_get_inf2(skill_id)&INF2_TRAP)) ) )
+		|| ((tsc && tsc->data[SC_REFLECTDAMAGE]) && !(dmg.flag&(BF_MAGIC|BF_LONG)) && !(skill_get_inf2(skill_id)&INF2_TRAP)) ) )
 		rdamage = battle_calc_return_damage(bl,src, &damage, dmg.flag, skill_id);
 
-	if( damage && sc && sc->data[SC_GENSOU] && dmg.flag&BF_MAGIC ){
+	if( damage && tsc && tsc->data[SC_GENSOU] && dmg.flag&BF_MAGIC ){
 		struct block_list *nbl;
 		nbl = battle_getenemyarea(bl,bl->x,bl->y,2,BL_CHAR,bl->id);
 		if( nbl ){ // Only one target is chosen.
@@ -2520,8 +2520,11 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
 		break;
 	case SL_STIN:
 	case SL_STUN:
-		if (skill_lv >= 7 && !sd->sc.data[SC_SMA])
-			sc_start(src,src,SC_SMA,100,skill_lv,skill_get_time(SL_SMA, skill_lv));
+		if (skill_lv >= 7){ 
+			struct status_change *sc = status_get_sc(src);
+			if(sc && !sc->data[SC_SMA])
+				sc_start(src,src,SC_SMA,100,skill_lv,skill_get_time(SL_SMA, skill_lv));
+		}
 		break;
 	case GS_FULLBUSTER:
 		if(sd) //Can't attack nor use items until skill's delay expires. [Skotlex]
@@ -2640,7 +2643,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
 
 	if(damage > 0 && dmg.flag&BF_SKILL && tsd
 		&& pc_checkskill(tsd,RG_PLAGIARISM)
-		&& (!sc || !sc->data[SC_PRESERVE])
+		&& (!tsc || !tsc->data[SC_PRESERVE])
 		&& damage < tsd->battle_status.hp)
 	{	//Updated to not be able to copy skills if the blow will kill you. [Skotlex]
 		int copy_skill = skill_id;
@@ -2678,7 +2681,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
 			can_copy(tsd,copy_skill,bl))	// Split all the check into their own function [Aru]
 		{
 			int lv;
-			if( sc && sc->data[SC__REPRODUCE] && (lv = sc->data[SC__REPRODUCE]->val1) ) {
+			if( tsc && tsc->data[SC__REPRODUCE] && (lv = tsc->data[SC__REPRODUCE]->val1) ) {
 				//Level dependent and limitation.
 				lv = min(lv,skill_get_max(copy_skill));
 				if( tsd->reproduceskill_id && tsd->status.skill[tsd->reproduceskill_id].flag == SKILL_FLAG_PLAGIARIZED ) {
@@ -2730,7 +2733,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
 
 	if( !dmg.amotion ) {
 		//Instant damage
-		if( !sc || (!sc->data[SC_DEVOTION] && skill_id != CR_REFLECTSHIELD) )
+		if( !tsc || (!tsc->data[SC_DEVOTION] && skill_id != CR_REFLECTSHIELD) )
 			status_fix_damage(src,bl,damage,dmg.dmotion); //Deal damage before knockback to allow stuff like firewall+storm gust combo.
 		if( !status_isdead(bl) && additional_effects )
 			skill_additional_effect(src,bl,skill_id,skill_lv,dmg.flag,dmg.dmg_lv,tick);
@@ -2802,8 +2805,8 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
 	if (dmg.amotion)
 		battle_delay_damage(tick, dmg.amotion,src,bl,dmg.flag,skill_id,skill_lv,damage,dmg.dmg_lv,dmg.dmotion, additional_effects);
 
-	if( sc && sc->data[SC_DEVOTION] && skill_id != PA_PRESSURE ) {
-		struct status_change_entry *sce = sc->data[SC_DEVOTION];
+	if( tsc && tsc->data[SC_DEVOTION] && skill_id != PA_PRESSURE ) {
+		struct status_change_entry *sce = tsc->data[SC_DEVOTION];
 		struct block_list *d_bl = map_id2bl(sce->val1);
 
 		if( d_bl && (
@@ -2851,7 +2854,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
 	}
 
 	if( rdamage > 0 ) {
-		if( sc && sc->data[SC_REFLECTDAMAGE] ) {
+		if( tsc && tsc->data[SC_REFLECTDAMAGE] ) {
 			if( src != bl )// Don't reflect your own damage (Grand Cross)
 				map_foreachinshootrange(battle_damage_area,bl,skill_get_splash(LG_REFLECTDAMAGE,1),BL_CHAR,tick,bl,dmg.amotion,sstatus->dmotion,rdamage,tstatus->race);
 		} else {
@@ -2898,9 +2901,9 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
 		(
 			skill_id == MG_COLDBOLT || skill_id == MG_FIREBOLT || skill_id == MG_LIGHTNINGBOLT
 		) &&
-		(sc = status_get_sc(src)) &&
-		sc->data[SC_DOUBLECAST] &&
-		rnd() % 100 < sc->data[SC_DOUBLECAST]->val2)
+		(tsc = status_get_sc(src)) &&
+		tsc->data[SC_DOUBLECAST] &&
+		rnd() % 100 < tsc->data[SC_DOUBLECAST]->val2)
 	{
 //		skill_addtimerskill(src, tick + dmg.div_*dmg.amotion, bl->id, 0, 0, skill_id, skill_lv, BF_MAGIC, flag|2);
 		skill_addtimerskill(src, tick + dmg.amotion, bl->id, 0, 0, skill_id, skill_lv, BF_MAGIC, flag|2);
@@ -14042,9 +14045,9 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16
 		case SL_STUN:
 		case SL_STIN:
 		{
-			int kaina_lv = pc_checkskill(sd,SL_KAINA);
+			int kaina_lv = sd?pc_checkskill(sd,SL_KAINA):skill_get_max(SL_KAINA);
 
-			if(kaina_lv==0 || sd->status.base_level<70)
+			if(kaina_lv==0 || !sd || sd->status.base_level<70)
 				break;
 			if(sd->status.base_level>=90)
 				req.sp -= req.sp*7*kaina_lv/100;

+ 1 - 1
src/map/status.c

@@ -1894,7 +1894,7 @@ static unsigned short status_base_atk(const struct block_list *bl, const struct
 	// [Skotlex]
 #ifdef RENEWAL
 	if (bl->type == BL_HOM)
-		str = floor((rstr + dex + status->luk) / 3) + floor(((TBL_HOM*)bl)->homunculus.level / 10);
+		str = (int)(floor((rstr + dex + status->luk) / 3) + floor(((TBL_HOM*)bl)->homunculus.level / 10));
 #endif
 	dstr = str/10;
 	str += dstr*dstr;