summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog-Trunk.txt2
-rw-r--r--doc/script_commands.txt11
-rw-r--r--npc/Changelog.txt1
-rw-r--r--npc/custom/eAAC_Scripts/quest_warper.txt5
-rw-r--r--npc/kafras/functions_kafras.txt15
-rw-r--r--sql-files/upgrade_svn13728.sql1
-rw-r--r--src/map/Makefile.in4
-rw-r--r--src/map/script.c16
-rw-r--r--vcproj-9/map-server_sql.vcproj8
-rw-r--r--vcproj-9/map-server_txt.vcproj8
10 files changed, 60 insertions, 11 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index 67e3b5350..cf99d95bf 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -3,6 +3,8 @@ Date Added
AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
+2009/05/04
+ * Added the md5() script command. [brianluau]
2009/05/03
* Updated item_db.sql and mob_db.sql from recent changes to both. Thanks to Peter once again! [Jguy]
* Do not log damage if it's done by mob itself (bugreport:2933) [Inkfish]
diff --git a/doc/script_commands.txt b/doc/script_commands.txt
index 1599058c8..24fc0b7f2 100644
--- a/doc/script_commands.txt
+++ b/doc/script_commands.txt
@@ -5917,6 +5917,17 @@ set @i, distance(100,200,101,202);
---------------------------------------
+*md5("<string>")
+
+Returns the md5 checksum of a number or string.
+
+Example:
+ mes md5(12345);
+ mes md5("12345"); // Will both display 827ccb0eea8a706c4c34a16891f84e7b
+ mes md5("qwerty"); // Will display d8578edf8458ce06fbc5bb76a58c5ca4
+
+---------------------------------------
+
*query_sql "your MySQL query", <array variable> {,<array variable>, ...};
*query_logsql "your MySQL query", <array variable> {,<array variable>, ...};
diff --git a/npc/Changelog.txt b/npc/Changelog.txt
index 0bd383e2e..b79a4ee6b 100644
--- a/npc/Changelog.txt
+++ b/npc/Changelog.txt
@@ -1,6 +1,7 @@
Date Added
======
2009/05/04
+ - The md5 checksum of the kafra code is now stored in #kafra_code$ [brianluau]
- Added a missing zeny check in the Jawaii Bartender. (bugreport:2897) [brianluau]
- Added a missing 'close' in the Mage quest Bookshelf. (bugreport:2873)
2009/05/03
diff --git a/npc/custom/eAAC_Scripts/quest_warper.txt b/npc/custom/eAAC_Scripts/quest_warper.txt
index 7ff06cd2e..650ee3a6e 100644
--- a/npc/custom/eAAC_Scripts/quest_warper.txt
+++ b/npc/custom/eAAC_Scripts/quest_warper.txt
@@ -71,6 +71,7 @@
// - Special warpname menu option name bug fixed
//-2.1 Updated names to fall within retrictions. [L0ne_W0lf]
//-2.2 #kafra_code is now stored as is. [brianluau]
+//-2.2b The md5() of their kafra code is now stored in #kafra_code$ [brianluau]
//=================================================================
//========================Function=&=Script========================
@@ -597,11 +598,11 @@ L_Storage:
end;
F_CheckKafCode:
- if(#kafra_code==0) return;
+ if(#kafra_code$=="") return;
mes "Enter your storage password:";
set @code_,0;
input @code_;
- if(@code_ != #kafra_code) {
+ if(md5(@code_) != #kafra_code$) {
dispbottom "Wrong storage password.";
close;
}
diff --git a/npc/kafras/functions_kafras.txt b/npc/kafras/functions_kafras.txt
index 4b65bbc9a..56382a31f 100644
--- a/npc/kafras/functions_kafras.txt
+++ b/npc/kafras/functions_kafras.txt
@@ -58,6 +58,7 @@
//= 6.1 Added menu for Turbo Track Kafra Staff. [L0ne_W0lf]
//= 6.2 Updated/Fixed warp cords. [Kisuka]
//= 6.3 #kafra_code is now stored as is. [brianluau]
+//= 6.3b The md5() of their kafra code is now stored in #kafra_code$ [brianluau]
//============================================================
@@ -557,11 +558,11 @@ function script F_KafEnd {
// Check Storage Password Function ====================
function script F_CheckKafCode {
- if(#kafra_code==0) return;
+ if(#kafra_code$=="") return;
mes "Enter your storage password:";
set @code_,0;
input @code_;
- if(@code_ != #kafra_code) {
+ if(md5(@code_) != #kafra_code$) {
dispbottom "Wrong storage password.";
close2;
cutin "",255;
@@ -576,7 +577,7 @@ function script F_CheckKafCode {
// getarg(0) = NPC Name, getarg(1) = Company Name
function script F_SetKafCode {
mes getarg(0);
- if(#kafra_code) {
+ if(#kafra_code$) {
mes "Your storage is protected with a password. What would you do now?";
next;
menu "Change old password -> 5000z",-,
@@ -593,7 +594,7 @@ function script F_SetKafCode {
mes getarg(0);
mes "At first, please enter your ^0000FFold password^000000.";
set @code,callfunc("F_EntKafCode");
- if(@code==0 || @code != #kafra_code) {
+ if(@code==0 || md5(@code) != #kafra_code$) {
mes "Wrong password. You can't set a new password.";
emotion e_hmm;
goto M_END;
@@ -615,7 +616,7 @@ M_SET:
set Zeny,Zeny-5000;
//set RESRVPTS, RESRVPTS + (5000/50); //hardcoded password doesn't add pts
- set #kafra_code,@code;
+ set #kafra_code$,md5(@code);
mes "You've protected your storage with a secret password.";
mes "Thank you for using "+getarg(1)+".";
emotion e_thx;
@@ -635,8 +636,8 @@ M_CLEAR:
if(Zeny < 1000) goto L_ZENY;
set Zeny,Zeny-1000;
//set RESRVPTS, RESRVPTS + (1000/50); //hardcoded password doesn't add pts
- if(@code == #kafra_code) {
- set #kafra_code,0;
+ if(md5(@code) == #kafra_code$) {
+ set #kafra_code$,"";
mes "You've successfully cleared your storage password.";
mes "Thank you for using "+getarg(1)+".";
emotion e_thx;
diff --git a/sql-files/upgrade_svn13728.sql b/sql-files/upgrade_svn13728.sql
new file mode 100644
index 000000000..6dc8301a5
--- /dev/null
+++ b/sql-files/upgrade_svn13728.sql
@@ -0,0 +1 @@
+UPDATE `global_reg_value` SET `str`='#kafra_code$',`value`=MD5(`value`) WHERE `str` = '#kafra_code';
diff --git a/src/map/Makefile.in b/src/map/Makefile.in
index 931b86c6a..10cf1ed39 100644
--- a/src/map/Makefile.in
+++ b/src/map/Makefile.in
@@ -3,12 +3,12 @@ COMMON_OBJ = ../common/obj_all/core.o ../common/obj_all/socket.o ../common/obj_a
../common/obj_all/db.o ../common/obj_all/plugins.o ../common/obj_all/lock.o \
../common/obj_all/nullpo.o ../common/obj_all/malloc.o ../common/obj_all/showmsg.o \
../common/obj_all/utils.o ../common/obj_all/strlib.o ../common/obj_all/grfio.o \
- ../common/obj_all/mapindex.o ../common/obj_all/ers.o
+ ../common/obj_all/mapindex.o ../common/obj_all/ers.o ../common/obj_all/md5calc.o
COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h \
../common/db.h ../common/plugins.h ../common/lock.h \
../common/nullpo.h ../common/malloc.h ../common/showmsg.h \
../common/utils.h ../common/strlib.h ../common/grfio.h \
- ../common/mapindex.h ../common/ers.h
+ ../common/mapindex.h ../common/ers.h ../common/md5calc.h
COMMON_SQL_OBJ = ../common/obj_sql/sql.o
COMMON_SQL_H = ../common/sql.h
diff --git a/src/map/script.c b/src/map/script.c
index 0bd5bbb35..a29b08423 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -9,6 +9,7 @@
#include "../common/cbasetypes.h"
#include "../common/malloc.h"
+#include "../common/md5calc.h"
#include "../common/lock.h"
#include "../common/nullpo.h"
#include "../common/showmsg.h"
@@ -11900,6 +11901,7 @@ BUILDIN_FUNC(pow)
script_pushint(st,(int)i);
return 0;
}
+
BUILDIN_FUNC(distance)
{
int x0, y0, x1, y1;
@@ -11914,6 +11916,19 @@ BUILDIN_FUNC(distance)
}
// <--- [zBuffer] List of mathematics commands
+
+BUILDIN_FUNC(md5)
+{
+ const char *tmpstr;
+ char *md5str;
+
+ tmpstr = script_getstr(st,2);
+ md5str = (char *)aMallocA((32+1)*sizeof(char));
+ MD5_String(tmpstr, md5str);
+ script_pushstr(st, md5str);
+ return 0;
+}
+
// [zBuffer] List of dynamic var commands --->
BUILDIN_FUNC(setd)
@@ -13900,6 +13915,7 @@ struct script_function buildin_func[] = {
BUILDIN_DEF(pow,"ii"),
BUILDIN_DEF(distance,"iiii"),
// <--- [zBuffer] List of mathematics commands
+ BUILDIN_DEF(md5,"s"),
// [zBuffer] List of dynamic var commands --->
BUILDIN_DEF(getd,"*"),
BUILDIN_DEF(setd,"*"),
diff --git a/vcproj-9/map-server_sql.vcproj b/vcproj-9/map-server_sql.vcproj
index 22da33b69..973e4bfad 100644
--- a/vcproj-9/map-server_sql.vcproj
+++ b/vcproj-9/map-server_sql.vcproj
@@ -255,6 +255,14 @@
>
</File>
<File
+ RelativePath="..\src\common\md5calc.c"
+ >
+ </File>
+ <File
+ RelativePath="..\src\common\md5calc.h"
+ >
+ </File>
+ <File
RelativePath="..\src\common\mapindex.c"
>
</File>
diff --git a/vcproj-9/map-server_txt.vcproj b/vcproj-9/map-server_txt.vcproj
index b0b8abe7f..5085acaf7 100644
--- a/vcproj-9/map-server_txt.vcproj
+++ b/vcproj-9/map-server_txt.vcproj
@@ -502,6 +502,14 @@
>
</File>
<File
+ RelativePath="..\src\common\md5calc.c"
+ >
+ </File>
+ <File
+ RelativePath="..\src\common\md5calc.h"
+ >
+ </File>
+ <File
RelativePath="..\src\common\mapindex.c"
>
</File>