Bläddra i källkod

Follow up 20695d629a59310a9e6a04c2234bbf4870609d90
* Fixed #304
* Fixed #308

Signed-off-by: Cydh Ramdh <house.bad@gmail.com>

Cydh Ramdh 10 år sedan
förälder
incheckning
714e670327
8 ändrade filer med 29 tillägg och 21 borttagningar
  1. 1 0
      src/char/int_homun.c
  2. 0 1
      src/common/mmo.h
  3. 3 3
      src/map/atcommand.c
  4. 12 3
      src/map/homunculus.c
  5. 2 2
      src/map/homunculus.h
  6. 8 9
      src/map/map.c
  7. 3 2
      src/map/mapreg.c
  8. 0 1
      src/map/mob.c

+ 1 - 0
src/char/int_homun.c

@@ -235,6 +235,7 @@ bool mapif_homunculus_delete(int homun_id)
 		Sql_ShowDebug(sql_handle);
 		return false;
 	}
+	ShowInfo("Homunculus '%d' has been deleted.\n", homun_id);
 	return true;
 }
 

+ 0 - 1
src/common/mmo.h

@@ -7,7 +7,6 @@
 #include "cbasetypes.h"
 #include "../common/db.h"
 #include <time.h>
-#include "../common/strlib.h"// StringBuf
 
 // server->client protocol version
 //        0 - pre-?

+ 3 - 3
src/map/atcommand.c

@@ -9120,9 +9120,9 @@ ACMD_FUNC(unloadnpcfile) {
 }
 ACMD_FUNC(cart) {
 #define MC_CART_MDFY(idx, x) \
-	sd->status.skill[(idx)].id = x?MC_PUSHCART:0; \
-	sd->status.skill[(idx)].lv = x?1:0; \
-	sd->status.skill[(idx)].flag = x?SKILL_FLAG_TEMPORARY:SKILL_FLAG_PERMANENT;
+	sd->status.skill[(idx)].id = (x)?MC_PUSHCART:0; \
+	sd->status.skill[(idx)].lv = (x)?1:0; \
+	sd->status.skill[(idx)].flag = (x)?SKILL_FLAG_TEMPORARY:SKILL_FLAG_PERMANENT;
 
 	int val = atoi(message);
 	bool need_skill = (pc_checkskill(sd, MC_PUSHCART) == 0);

+ 12 - 3
src/map/homunculus.c

@@ -282,7 +282,7 @@ void hom_calc_skilltree(struct homun_data *hd, bool flag_evolve) {
 
 	/* load previous homunculus form skills first. */
 	if (hd->homunculus.prev_class != 0 && (c = hom_class2index(hd->homunculus.prev_class)) >= 0) {
-		for (i = 0; i < MAX_SKILL_TREE; i++) {
+		for (i = 0; i < MAX_HOM_SKILL_TREE; i++) {
 			uint16 skill_id;
 			short idx = -1;
 			bool fail = false;
@@ -312,7 +312,7 @@ void hom_calc_skilltree(struct homun_data *hd, bool flag_evolve) {
 	if ((c = hom_class2index(hd->homunculus.class_)) < 0)
 		return;
 
-	for (i = 0; i < MAX_SKILL_TREE; i++) {
+	for (i = 0; i < MAX_HOM_SKILL_TREE; i++) {
 		unsigned int intimacy = 0;
 		uint16 skill_id;
 		short idx = -1;
@@ -1525,11 +1525,18 @@ static bool read_homunculus_skilldb_sub(char* split[], int columns, int current)
 	}
 
 	skill_id = atoi(split[1]);
-	if ((idx = hom_skill_get_index(skill_id)) == -1) {
+	if (hom_skill_get_index(skill_id) == -1) {
 		ShowError("read_homunculus_skilldb: Invalid Homunculus skill '%s'.\n", split[1]);
 		return false;
 	}
 
+	// Search an empty line or a line with the same skill_id (stored in idx)
+	ARR_FIND(0, MAX_HOM_SKILL_TREE, idx, !hskill_tree[class_idx][idx].id || hskill_tree[class_idx][idx].id == skill_id);
+	if (idx == MAX_HOM_SKILL_TREE) {
+		ShowWarning("Unable to load skill %d into homunculus %d's tree. Maximum number of skills per class has been reached.\n", skill_id, atoi(split[0]));
+		return false;
+	}
+
 	hskill_tree[class_idx][idx].id = skill_id;
 	hskill_tree[class_idx][idx].max = atoi(split[2]);
 	hskill_tree[class_idx][idx].need_level = atoi(split[3]);
@@ -1608,9 +1615,11 @@ void hom_reload_skill(void){
 
 void do_init_homunculus(void){
 	int class_;
+
 	read_homunculusdb();
 	read_homunculus_expdb();
 	read_homunculus_skilldb();
+
 	// Add homunc timer function to timer func list [Toms]
 	add_timer_func_list(hom_hungry, "hom_hungry");
 

+ 2 - 2
src/map/homunculus.h

@@ -137,10 +137,10 @@ enum e_homun_grade {
 };
 
 /// Check Homunculus Class ID
-#define homdb_checkid(id) (id >=  HM_CLASS_BASE && id <= HM_CLASS_MAX)
+#define homdb_checkid(id) ((id) >=  HM_CLASS_BASE && (id) <= HM_CLASS_MAX)
 
 // merc_is_hom_alive(struct homun_data *)
-#define hom_is_active(x) (x && x->homunculus.vaporize == HOM_ST_ACTIVE && x->battle_status.hp > 0)
+#define hom_is_active(x) ((x) && (x)->homunculus.vaporize == HOM_ST_ACTIVE && (x)->battle_status.hp > 0)
 int hom_recv_data(uint32 account_id, struct s_homunculus *sh, int flag); //albator
 struct view_data* hom_get_viewdata(int class_);
 int hom_class2mapid(int hom_class);

+ 8 - 9
src/map/map.c

@@ -3817,14 +3817,14 @@ int map_sql_init(void)
 	if( SQL_ERROR == Sql_Connect(mmysql_handle, map_server_id, map_server_pw, map_server_ip, map_server_port, map_server_db) ||
 		SQL_ERROR == Sql_Connect(qsmysql_handle, map_server_id, map_server_pw, map_server_ip, map_server_port, map_server_db) )
 	{
-            ShowError("Couldn't connect with uname='%s',passwd='%s',host='%s',port='%d',database='%s'\n",
-                        map_server_id, map_server_pw, map_server_ip, map_server_port, map_server_db);
-            Sql_ShowDebug(mmysql_handle);
-            Sql_Free(mmysql_handle);
-            Sql_ShowDebug(qsmysql_handle);
-            Sql_Free(qsmysql_handle);
-            exit(EXIT_FAILURE);
-        }
+		ShowError("Couldn't connect with uname='%s',passwd='%s',host='%s',port='%d',database='%s'\n",
+			map_server_id, map_server_pw, map_server_ip, map_server_port, map_server_db);
+		Sql_ShowDebug(mmysql_handle);
+		Sql_Free(mmysql_handle);
+		Sql_ShowDebug(qsmysql_handle);
+		Sql_Free(qsmysql_handle);
+		exit(EXIT_FAILURE);
+	}
 	ShowStatus("Connect success! (Map Server Connection)\n");
 
 	if( strlen(default_codepage) > 0 ) {
@@ -3833,7 +3833,6 @@ int map_sql_init(void)
 		if ( SQL_ERROR == Sql_SetEncoding(qsmysql_handle, default_codepage) )
 			Sql_ShowDebug(qsmysql_handle);
 	}
-
 	return 0;
 }
 

+ 3 - 2
src/map/mapreg.c

@@ -7,8 +7,10 @@
 #include "../common/sql.h"
 #include "../common/strlib.h"
 #include "../common/timer.h"
+
 #include "map.h" // mmysql_handle
 #include "script.h"
+
 #include <stdlib.h>
 
 static DBMap* mapreg_db = NULL; // int var_id -> int value
@@ -70,7 +72,7 @@ bool mapreg_setregstr(int uid, const char* str)
 	int num = (uid & 0x00ffffff);
 	int i   = (uid & 0xff000000) >> 24;
 	const char* name = get_str(num);
-	
+
 	if( str == NULL || *str == 0 )
 	{
 		if(name[1] != '@') {
@@ -134,7 +136,6 @@ static void script_load_mapreg(void)
 		else
 			idb_iput(mapreg_db, (i<<24)|s, atoi(value));
 	}
-	
 	SqlStmt_Free(stmt);
 
 	mapreg_dirty = false;

+ 0 - 1
src/map/mob.c

@@ -4438,7 +4438,6 @@ static int mob_read_sqlskilldb(void)
 		return 0;
 	}
 
-
 	for( fi = 0; fi < ARRAYLENGTH(mob_skill_db_name); ++fi ) {
 		uint32 lines = 0, count = 0;