summaryrefslogtreecommitdiff
path: root/src/map/skill.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-12-23 16:32:45 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-12-23 16:32:45 +0000
commit9e76b6474486bb97e4acf0dae0c1c8311d7544d5 (patch)
treec5449946aaa7cd4909781a507ced107f93009a55 /src/map/skill.c
parenta050a1a8a1bb9e5a61a3b9ac60e1e688e98c4ea3 (diff)
downloadhercules-9e76b6474486bb97e4acf0dae0c1c8311d7544d5.tar.gz
hercules-9e76b6474486bb97e4acf0dae0c1c8311d7544d5.tar.bz2
hercules-9e76b6474486bb97e4acf0dae0c1c8311d7544d5.tar.xz
hercules-9e76b6474486bb97e4acf0dae0c1c8311d7544d5.zip
- Fixed horrible handling of skill_abra_db which leads to memory corruption (depending on the contents of yor abra_db.txt file)
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11970 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/skill.c')
-rw-r--r--src/map/skill.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/src/map/skill.c b/src/map/skill.c
index 8c87060c7..31b919fd4 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -3023,16 +3023,12 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
{
int abra_skillid = 0, abra_skilllv;
do {
- abra_skillid = rand() % MAX_SKILL_ABRA_DB;
- if (
-//Unneeded check, use the "per" field to know if the skill is valid.
-// skill_get_inf2(abra_skillid)&(INF2_NPC_SKILL|INF2_SONG_DANCE|INF2_ENSEMBLE_SKILL) || //NPC/Song/Dance skills are out
- !skill_get_inf(abra_skillid) || //Passive skills cannot be casted
- skill_abra_db[abra_skillid].req_lv > skilllv || //Required lv for it to appear
- rand()%10000 >= skill_abra_db[abra_skillid].per
- )
- abra_skillid = 0; // reset to get a new id
- } while (abra_skillid == 0);
+ i = rand() % MAX_SKILL_ABRA_DB;
+ abra_skillid = skill_abra_db[i].skillid;
+ } while (abra_skillid == 0 ||
+ skill_abra_db[i].req_lv > skilllv || //Required lv for it to appear
+ rand()%10000 >= skill_abra_db[i].per
+ );
abra_skilllv = min(skilllv, skill_get_max(abra_skillid));
clif_skill_nodamage (src, bl, skillid, skilllv, 1);
@@ -11015,14 +11011,23 @@ static bool skill_parse_row_createarrowdb(char* split[], int columns, int curren
static bool skill_parse_row_abradb(char* split[], int columns, int current)
{// SkillID,DummyName,RequiredHocusPocusLevel,Rate
int i = atoi(split[0]);
- i = skill_get_index(i);
- if( !i )
+ if( !skill_get_index(i) || !skill_get_max(i) )
+ {
+ ShowError("abra_db: Invalid skill ID %d\n", i);
return false;
- if( current == MAX_SKILL_ABRA_DB )
+ }
+ if ( !skill_get_inf(i) )
+ {
+ ShowError("abra_db: Passive skills cannot be casted (%d/%s)\n", i, skill_get_name(i));
return false;
+ }
- skill_abra_db[i].req_lv = atoi(split[2]);
- skill_abra_db[i].per = atoi(split[3]);
+ if( current == MAX_SKILL_ABRA_DB )
+ return false;
+
+ skill_abra_db[current].skillid = i;
+ skill_abra_db[current].req_lv = atoi(split[2]);
+ skill_abra_db[current].per = atoi(split[3]);
//TODO?: add capacity warning here