rathena/tools/check-doc.pl
Cydh Ramdh ce090ce916 Skill Changes:
* Wizard/Warlock Skill
  * Moved Sightrasher (WZ_SIGHTRASHER) requirement to check Sight (SC_SIGHT) is active or not to skill_check_condition_castend section.
  * Fixed Sightrasher (WZ_SIGHTRASHER) splash area to 3x3. (bugreport:9298)
  * Now Comet (WL_COMET) cannot hits Hiding target (The mistake is not at flag 0x10000 in skill_db.txt, the flash should be added by SD_ANIMATION). (bugreport:8909).
  * Now Reading Spell Book (WL_READING_SB) checking the number of available spell books in Spell Book DB first to prevent infinite loop.
* Sage Skill
  * Now Abracadabra (SA_ABRACADABRA) checking the number of available skills in Abra DB first to prevent infinite loop.
  * Reduced MAX_SKILL_ABRA_DB from 350 to 160.
* Shadow Chaser Skill
  * Fixed Chaos Panic (SC_CHAOSPANIC) effect. (bugreport:9321).
* Genetic Skill
  * Now Wall of Thorn (GN_WALLOFTHORN) can be knocked back but not a whole skill group and durability (HP & max hit) for each skill unit.
* Guillotine Cross Skill
  * Now Magic Mushroom (SC_MAGICMUSHROOM) effect checks the number of available skills in Magic Mushroom DB first to prevent infinite loop.
  * Changed 'RemoveFlag' in db/magicmushroom_db.txt value to 1 to remove skill by importing. (bugreport:9322).
* Wanderer/Minstrel Skill
  * Now Randomize Spell (WM_RANDOMIZESPELL) checks the number of available skills in Improvise DB first to prevent infinite loop.
  * Reduced MAX_SKILL_IMPROVISE_DB from 50 to 30.
* Rebellion Skill
  * Cleaned up, added, corrected some (missing) sequences & DB values.
  * Fixed Hammer of God (RL_HAMMER_OF_GOD) splash damage.
  * Fixed Shaterred Strom (RL_S_STORM) push back & force to sit effect (for player, or stun for monsters) (first implementation leftover).
  * Fixed Slug Shot (RL_SLUGSHOT) hitrate-distance penalty (first implementation leftover).
  * Fixed Howling Mine (RL_H_MINE) damage ratios (first implementation leftover).
  * Now Bind Trap (RL_B_TRAP) only can be placed 1 at same time.
  * Fixed Bind Trap (RL_B_TRAP) damage calculation by using Caster's DEX, Target's Current HP, & Skill Level. FIXME: Exact formula still unknown (refers to idAthena formula).
  * Now Dragon Tail (RL_D_TAIL) doesn't split damage among targets anymore.
  * Now Crimson Marker (RL_C_MARKER) will fails to cast if no slot available.
  * Implemented official packet `ZC_C_MARKERINFO` of Crimson Marker (RL_C_MARKER) mini-map marker (first implementation leftover). !TODO: Confirm the packet for older or newer clients (idAthena partial merge r1497)
  * References: http://forums.irowiki.org/showpost.php?p=1387992&postcount=968, follow up 507f047, dd67f9d

Misc:
* Fixed some skills that should work only in shoot range (map_foreachinshootange, by default), and added check for respecting *skill_wall_check* (map_foreachinrange).
* Fixed item stackable check for `/item` command, follow up 9b4d922.
* Fixed npc source file isn't removed properly by @unloadnpcfile. (bugreport:9311).
* Added constantan for status_change_start() and sc_start() scripts as well
  * SCSTART_NONE = 0x0
  * SCSTART_NOAVOID = 0x1
  * SCSTART_NOTICKDEF = 0x2
  * SCSTART_LOADED = 0x4
  * SCSTART_NORATEDEF = 0x8
  * SCSTART_NOICON = 0x10
* Moved and changed itemdb_unique_id() to pc_generate_unique_id().
* Seperated check for skill SC requirement to skill_check_condition_sc_required().
* Added skill unit flag `UF_KNOCKBACK_GROUP`, just an option to make skill unit can be knocked back a whole group.
* Typos and other minor changes!

Signed-off-by: Cydh Ramdh <house.bad@gmail.com>
2014-10-01 17:42:30 +07:00

252 lines
7.4 KiB
Perl
Executable File

#!/usr/bin/perl
# checking-doc original script by trojal
# modified by lighta
use strict;
use File::Basename;
use Getopt::Long;
my $sHelp = 0;
my $sAtcf = "../doc/atcommands.txt";
my $sSctf = "../doc/script_commands.txt";
my $sLeftOverChk = 0;
my $sCmd = "chk";
my $sValidCmd = "ls|chk";
my $sTarget = "All";
my $sValidTarget = "All|Script|Atc";
my $sInc_atcf = "../doc/atcommands2.txt";
my $sInc_scrtf = "../doc/script_commands2.txt";
my($filename, $dir, $suffix) = fileparse($0);
chdir $dir; #put ourself like was called in tool folder
GetArgs();
Main($sCmd,$sTarget);
sub GetArgs {
GetOptions(
'cmd=s' => \$sCmd, # which command to run
'atcf=s' => \$sAtcf, #atcommand doc file
'scriptf=s' => \$sSctf, #script doc file
'inc_atcf=s' => \$sInc_atcf, #include script doc file (for customs doc)
'inc_scrtf=s' => \$sInc_scrtf, #include script doc file (for customs doc)
'target=s' => \$sTarget, #Target (wich files to run-cmd into)
'leftover=i' => \$sLeftOverChk, #should we chk if all doc are linked to a src ?
'help!' => \$sHelp,
) or $sHelp=1; #display help if invalid option
if( $sHelp ) {
print "Incorrect option specified, available options are:\n"
."\t --atcf filename => file (specify atcommand doc to use)\n"
."\t --inc_atcf filename => include file (specify atcommand doc to use)\n"
."\t --scriptf filename => file (specify script doc to use)\n"
."\t --inc_scrtf filename => include file (specify script doc to use)\n"
."\t --leftover=0|1 => should we run reverse chk for leftover in documentation ?\n"
."\t --target => target (specify wich check to run [$sValidTarget])\n"
."\t --cmd => cmd (specify wich command to run [(default)$sValidCmd])\n";
exit;
}
unless($sTarget =~ /$sValidTarget/i){
print "Incorrect target specified, available target is:\n"
."\t --target => target (specify wich check to run [(default)$sValidTarget])\n";
exit;
}
unless($sCmd =~ /$sValidCmd/i){
print "Incorrect command specified, available command is:\n"
."\t --cmd => cmd (specify wich command to run [(default)$sValidCmd])\n";
exit;
}
}
sub Main { my ($sCmd,$sTarget) = @_;
if($sTarget=~/both|all/i){ #both is keep as backard compatibility here cf check-doc.sh
$sTarget = "script|atc";
}
if($sTarget=~/script/i){ #find which script commands are missing from doc/script_commands.txt
my $raSct_cmd = Script_GetCmd();
if($sCmd =~ /ls/i) {
print "The list of script-commands found are = \n[ @$raSct_cmd ] \n\n";
}
if($sCmd =~ /chk/i) { Script_Chk($raSct_cmd); }
}
if($sTarget=~/atc/i){ #find which atcommands are missing from doc/atcommands.txt
my $raAct_cmd = Atc_GetCmd();
if($sCmd =~ /ls/i) {
print "The list of atcommands found are = \n[ @$raAct_cmd ] \n\n";
}
if($sCmd =~ /chk/i) { Atc_Chk($raAct_cmd); }
}
}
sub Chk { my($raA,$raB) = @_;
my @aMissing = ();
foreach my $sA (@$raA){
my $sFound = 0;
foreach my $sB (@$raB){
$sFound=1 if($sA eq $sB);
}
unless($sFound){
push(@aMissing,$sA);
}
}
return \@aMissing;
}
sub Script_GetCmd {
my @aSct_src = ("../src/map/script.c","../src/custom/script_def.inc");
my @aDef_sct = ();
foreach my $sSct_srcf (@aSct_src){
unless(open FILE_SRC, "<$sSct_srcf") {
print "couldn't open file $sSct_srcf \n";
next;
}
while(<FILE_SRC>){
next if($_ =~ /^#/); #ignoe include, define or macro
if($_ =~ /BUILDIN_DEF|BUILDIN_DEF2/){
$_ =~ s/\s+$//; #Remove trailing spaces.
$_ =~ s/^\s+//; #Remove leading spaces.
if($_ =~ /^BUILDIN_DEF2/){
my @line = split('"',$_);
push(@aDef_sct,$line[1]);
}
elsif($_ =~ /^BUILDIN_DEF/){
my @line = split(',',$_);
@line = split('\(',$line[0]);
push(@aDef_sct,$line[1]);
}
}
}
close FILE_SRC;
}
return \@aDef_sct;
}
sub Script_Chk { my ($raDef_sct) = @_;
my @aSct_docf = ($sSctf,$sInc_scrtf);
my @aDoc_sct = ();
my $raMiss_sct;
foreach my $sSct_docf (@aSct_docf){
unless(open FILE_DOC, "$sSct_docf"){
print "couldn't open file $sSct_docf \n";
next;
}
while(<FILE_DOC>){
next if($_ =~ /^\*\*|^\*\s|^\s+/); #discard **, * foo, foo
next if(/^\s+/);
if($_ =~ /^\*/){
my @line = split(' ',$_);
@line = split('\(',$line[0]);
@line = split('\<',$line[0]);
$line[0] =~ s/\(|\{|\*|\r|\s|\;|\)|\"|\,//g; #todo please harmonize command definition for easier parse
next if($line[0] eq "Name" || $line[0] eq "" || $line[0] eq "function"
|| $line[0] eq "if" || $line[0] eq "while" || $line[0] eq "do" || $line[0] eq "for" ); #exception list
push(@aDoc_sct,$line[0]);
}
}
close FILE_DOC;
}
$raMiss_sct = Chk($raDef_sct,\@aDoc_sct); #check missing documentation
if(scalar(@$raMiss_sct)){
print "Missing script documentation for function :{\n";
foreach(@$raMiss_sct){
print "\t$_ \n";
}
print "}\n\n";
}
else { print "All script command in Src are documented, no issues found\n"; }
if($sLeftOverChk){
my $raLeftover_sct = Chk(\@aDoc_sct,$raDef_sct); #we just inverse the chk for leftover
if(scalar(@$raLeftover_sct)){
print "Those script command was found in doc but no source associated, leftover ? :{\n";
foreach(@$raLeftover_sct){
print "\t$_ \n";
}
print "}\n\n";
}
else { print "All script command in documentation match a source BUILDIN, no leftover found\n"; }
}
}
sub Atc_GetCmd {
my @aAct_src = ("../src/map/atcommand.c","../src/custom/atcommand_def.inc");
my @aDef_act = ();
foreach my $sAct_srcf (@aAct_src){
unless(open FILE_SRC, "<$sAct_srcf"){
print "couldn't open file $sAct_srcf \n";
next;
}
while(<FILE_SRC>){
next if($_ =~ /^#/); #ignore include, define or macro
if($_ =~ /ACMD_DEF|ACMD_DEF2|ACMD_DEFR|ACMD_DEF2R/){
$_ =~ s/\s+$//; #Remove trailing spaces.
$_ =~ s/^\s+//; #Remove leading spaces.
if($_ =~ /^ACMD_DEF2|^ACMD_DEF2R/){
my @line = split('"',$_);
push(@aDef_act,$line[1]);
}
elsif($_ =~ /^ACMD_DEF|^ACMD_DEFR/){
my @line = split(',',$_);
@line = split('\(',$line[0]);
$line[1] =~ s/\)//; #Remove closing brace
push(@aDef_act,$line[1]);
}
}
}
close FILE_SRC;
}
return \@aDef_act;
}
sub Atc_Chk { my ($raDef_act) = @_;
my @aAct_docf = ($sAtcf,$sInc_atcf);
my @aDoc_act = ();
my $raMiss_act;
foreach my $sAct_docf (@aAct_docf){
unless(open FILE_DOC, "$sAct_docf"){
print "couldn't open file $sAct_docf \n";
next;
}
while(<FILE_DOC>){
next if($_ =~ /^\*\*|^\*\s|^\s+/); #discard **, * foo, foo
next if(/^\s+/);
if($_ =~ /^\@/){
my @line = split(' ',$_);
@line = split('\(',$line[0]);
@line = split('\<',$line[0]);
$line[0] =~ s/\(|\{|\@|\r|\s|\;|\)|\"|\,//g; #todo please harmonize command definition for easier parse
push(@aDoc_act,$line[0]);
}
}
close FILE_DOC;
}
$raMiss_act = Chk($raDef_act,\@aDoc_act); #check missing documentation
if(scalar(@$raMiss_act)){
print "Missing atcommand documentation for function :{\n";
foreach(@$raMiss_act){
print "\t$_ \n";
}
print "}\n\n";
}
else { print "All atcommand in Src are documented, no issues found\n"; }
if($sLeftOverChk){
my $raLeftover_sct = Chk(\@aDoc_act,$raDef_act); #we just inverse the chk for leftover
if(scalar(@$raLeftover_sct)){
print "Those atcommands were found in doc but no source associated, leftover ? : {\n";
foreach(@$raLeftover_sct){
print "\t$_ \n";
}
print "}\n\n";
}
else { print "All atcommands in documentation match a source ATCMD, no leftover found\n"; }
}
}