Browse Source

- Changed the script source from unsigned char* to const char*.
- Updated plugins Makefile.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@9532 54d463be-8e91-2dee-dedb-b68131a5f0ec

FlavioJS 18 years ago
parent
commit
40b389bc42
8 changed files with 408 additions and 413 deletions
  1. 3 0
      Changelog-Trunk.txt
  2. 151 151
      npc/sample/localized_npc.txt
  3. 6 0
      src/common/cbasetypes.h
  4. 3 3
      src/map/map.h
  5. 4 4
      src/map/npc.c
  6. 187 202
      src/map/script.c
  7. 2 2
      src/map/script.h
  8. 52 51
      src/plugins/Makefile

+ 3 - 0
Changelog-Trunk.txt

@@ -3,6 +3,9 @@ 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.
 
+2006/12/20
+	* Changed the script source from unsigned char* to const char*.
+	* Updated plugins Makefile. [FlavioJS]
 2006/12/19
 	* Reverted the mob ThinkTime update, that field is again aDelay as it
 	  apparently should be. [Skotlex]

+ 151 - 151
npc/sample/localized_npc.txt

@@ -1,151 +1,151 @@
-//===== eAthena Script ======================================= 
-//= Sample localized NPC
-//===== By: ================================================== 
-//= eAthena Dev Team
-//===== Current Version: ===================================== 
-//= v1.0
-//===== Compatible With: ===================================== 
-//= eAthena with setd, getd and npc variables '.'
-//===== Description: ========================================= 
-//= Example of a localized NPC.
-//= 
-//= There are many ways to do it, this is just one option.
-//= The player has a global account variable ##_langid_ that 
-//= identifies the it's language.
-//= 
-//= The default language should always have langid 0.
-//= When a message isn't found for the player's langid 
-//= (strlen = 0), the message from langid 0 is used instead.
-//= 
-//= Each message is identified by a string that must only 
-//= contain valid variable name characters.
-//= 
-//= void setlang(int langid)
-//= - sets the player's language
-//= int getlang(void)
-//= - returns the player's language
-//= void setmes2(string name,int langid,string text)
-//= - sets the localized text for name
-//= string getmes2(string name,int langid)
-//= - returns the localized text of name
-//= void mes2(string name)
-//= - displays the localized text of name
-//= 
-//===== Additional Comments: ================================= 
-//= To use this globally, just put the functions in Global_Functions.txt
-//============================================================ 
-
-//////////////////////////////////////////////////////////////
-/// Sets the language of the player account.
-/// @param langid	Languange identifier (0 for default)
-function	script	setlang	{
-	set ##_langid_, getarg(0);
-	return;
-}
-
-//////////////////////////////////////////////////////////////
-/// Returns the language identifier of the player
-function	script	getlang	{
-	return ##_langid_;
-}
-
-//////////////////////////////////////////////////////////////
-/// Sets a localized text entry.
-/// Does not need a RID attached.
-/// @param name	Message identifier
-/// @param langid	Language identifier (0 for default)
-/// @param text	Text message
-function	script	setmes2	{
-	set $@mes2_name$, getarg(0);
-	set $@mes2_langid, getarg(1);
-	set $@mes2_text$, getarg(2);
-	set $@mes2_var$, "$@__"+ $@mes2_name$ +"_"+ $@mes2_langid +"$";
-
-	//debugmes "setmes2 \""+ $@mes2_var$ +"\", \""+ $@mes2_text$ +"\";";
-
-	// set the localized text
-	setd $@mes2_var$, $@mes2_text$;
-	return;
-}
-
-//////////////////////////////////////////////////////////////
-/// Sets a localized text entry.
-/// Does not need a RID attached.
-/// @param name	Message identifier
-/// @param langid	Language identifier (0 for default)
-/// @return	Text message
-function	script	getmes2	{
-	set $@mes2_name$, getarg(0);
-	set $@mes2_langid, getarg(1);
-	set $@mes2_var$, "$@__"+ $@mes2_name$ +"_"+ $@mes2_langid +"$";
-	set $@mes2_text$, getd($@mes2_var$);
-
-	//debugmes "getmes2(\""+ $@mes2_var$ +"\")=\""+ $@mes2_text$ +"\"";
-
-	return $@mes2_text$;
-}
-
-//////////////////////////////////////////////////////////////
-/// mes for localized text.
-/// index should be a unique string, made up only of characters 
-/// that are valis as a variable name
-/// @param index	Message identifier
-function	script	mes2	{
-	set .@mes2_index$, getarg(0);
-
-	if( getstrlen(.@mes2_index$) == 0 )
-		return; // invalid index
-
-	// print localized text
-	set .@mes2_text$, callfunc("getmes2",.@mes2_index$,##_langid_);
-	if( getstrlen(.@mes2_text$) == 0 )
-	{
-		if( ##_langid_ != 0 )
-		{// revert to default language
-			set .@mes2_text$, callfunc("getmes2",.@mes2_index$,0);
-			if( getstrlen(.@mes2_text$) != 0 )
-				mes .@mes2_text$; // default text
-		}
-	} else
-		mes .@mes2_text$; // localized text
-	return;
-}
-
-//////////////////////////////////////////////////////////////
-/// Sample localized NPC
-prontera.gat,155,183,4	script	LocalizedNPC	705,{
-	// Get text for specific languages
-	set .@menu1$, callfunc("getmes2","LNPC_lang",0);
-	set .@menu2$, callfunc("getmes2","LNPC_lang",1);
-	do {
-		// get text that fallbacks to language 0
-		callfunc "mes2", "LNPC_name";
-		// localized mes
-		callfunc "mes2", "LNPC_lang";
-		callfunc "mes2", "LNPC_text";
-		next;
-
-		switch(select(.@menu1$,.@menu2$,"Cancel"))
-		{
-			case 1:
-			case 2:
-				// Set player language
-				callfunc "setlang",@menu-1;
-				break;
-		}
-	} while( @menu != 3 );
-	close;
-	end;
-
-OnInterIfInitOnce:
-	// Load the localized text.
-	// This can be anywhere, as long as it's executed before the coresponding getmes2/mes2 calls
-	//  0 - English (default)
-	//  1 - Portuguese
-	callfunc "setmes2", "LNPC_name", 0, "[LocalizedNPC]";
-	callfunc "setmes2", "LNPC_lang", 0, "EN";
-	callfunc "setmes2", "LNPC_lang", 1, "PT";
-	callfunc "setmes2", "LNPC_text", 0, "Something in english";
-	callfunc "setmes2", "LNPC_text", 1, "Algo em português";
-	end;
-}
+//===== eAthena Script ======================================= 
+//= Sample localized NPC
+//===== By: ================================================== 
+//= eAthena Dev Team
+//===== Current Version: ===================================== 
+//= v1.0
+//===== Compatible With: ===================================== 
+//= eAthena with setd, getd
+//===== Description: ========================================= 
+//= Example of a localized NPC.
+//= 
+//= There are many ways to do it, this is just one option.
+//= The player has a global account variable ##_langid_ that 
+//= identifies the it's language.
+//= 
+//= The default language should always have langid 0.
+//= When a message isn't found for the player's langid 
+//= (strlen = 0), the message from langid 0 is used instead.
+//= 
+//= Each message is identified by a string that must only 
+//= contain valid variable name characters.
+//= 
+//= void setlang(int langid)
+//= - sets the player's language
+//= int getlang(void)
+//= - returns the player's language
+//= void setmes2(string name,int langid,string text)
+//= - sets the localized text for name
+//= string getmes2(string name,int langid)
+//= - returns the localized text of name
+//= void mes2(string name)
+//= - displays the localized text of name
+//= 
+//===== Additional Comments: ================================= 
+//= To use this globally, just put the functions in Global_Functions.txt
+//============================================================ 
+
+//////////////////////////////////////////////////////////////
+/// Sets the language of the player account.
+/// @param langid	Languange identifier (0 for default)
+function	script	setlang	{
+	set ##_langid_, getarg(0);
+	return;
+}
+
+//////////////////////////////////////////////////////////////
+/// Returns the language identifier of the player
+function	script	getlang	{
+	return ##_langid_;
+}
+
+//////////////////////////////////////////////////////////////
+/// Sets a localized text entry.
+/// Does not need a RID attached.
+/// @param name	Message identifier
+/// @param langid	Language identifier (0 for default)
+/// @param text	Text message
+function	script	setmes2	{
+	set $@mes2_name$, getarg(0);
+	set $@mes2_langid, getarg(1);
+	set $@mes2_text$, getarg(2);
+	set $@mes2_var$, "$@__"+ $@mes2_name$ +"_"+ $@mes2_langid +"$";
+
+	//debugmes "setmes2 \""+ $@mes2_var$ +"\", \""+ $@mes2_text$ +"\";";
+
+	// set the localized text
+	setd $@mes2_var$, $@mes2_text$;
+	return;
+}
+
+//////////////////////////////////////////////////////////////
+/// Sets a localized text entry.
+/// Does not need a RID attached.
+/// @param name	Message identifier
+/// @param langid	Language identifier (0 for default)
+/// @return	Text message
+function	script	getmes2	{
+	set $@mes2_name$, getarg(0);
+	set $@mes2_langid, getarg(1);
+	set $@mes2_var$, "$@__"+ $@mes2_name$ +"_"+ $@mes2_langid +"$";
+	set $@mes2_text$, getd($@mes2_var$);
+
+	//debugmes "getmes2(\""+ $@mes2_var$ +"\")=\""+ $@mes2_text$ +"\"";
+
+	return $@mes2_text$;
+}
+
+//////////////////////////////////////////////////////////////
+/// mes for localized text.
+/// index should be a unique string, made up only of characters 
+/// that are valis as a variable name
+/// @param index	Message identifier
+function	script	mes2	{
+	set @mes2_index$, getarg(0);
+
+	if( getstrlen(@mes2_index$) == 0 )
+		return; // invalid index
+
+	// print localized text
+	set @mes2_text$, callfunc("getmes2",@mes2_index$,##_langid_);
+	if( getstrlen(@mes2_text$) == 0 )
+	{
+		if( ##_langid_ != 0 )
+		{// revert to default language
+			set @mes2_text$, callfunc("getmes2",@mes2_index$,0);
+			if( getstrlen(@mes2_text$) != 0 )
+				mes @mes2_text$; // default text
+		}
+	} else
+		mes @mes2_text$; // localized text
+	return;
+}
+
+//////////////////////////////////////////////////////////////
+/// Sample localized NPC
+prontera.gat,155,183,4	script	LocalizedNPC	705,{
+	// Get text for specific languages
+	set @menu1$, callfunc("getmes2","LNPC_lang",0);
+	set @menu2$, callfunc("getmes2","LNPC_lang",1);
+	do {
+		// get text that fallbacks to language 0
+		callfunc "mes2", "LNPC_name";
+		// localized mes
+		callfunc "mes2", "LNPC_lang";
+		callfunc "mes2", "LNPC_text";
+		next;
+
+		switch(select(@menu1$,@menu2$,"Cancel"))
+		{
+			case 1:
+			case 2:
+				// Set player language
+				callfunc "setlang",@menu-1;
+				break;
+		}
+	} while( @menu != 3 );
+	close;
+	end;
+
+OnInterIfInitOnce:
+	// Load the localized text.
+	// This can be anywhere, as long as it's executed before the coresponding getmes2/mes2 calls
+	//  0 - English (default)
+	//  1 - Portuguese
+	callfunc "setmes2", "LNPC_name", 0, "[LocalizedNPC]";
+	callfunc "setmes2", "LNPC_lang", 0, "EN";
+	callfunc "setmes2", "LNPC_lang", 1, "PT";
+	callfunc "setmes2", "LNPC_text", 0, "Something in english";
+	callfunc "setmes2", "LNPC_text", 1, "Algo em português";
+	end;
+}

+ 6 - 0
src/common/cbasetypes.h

@@ -286,4 +286,10 @@ typedef char bool;
 #endif
 #endif /* ! defined(Assert) */
 
+//////////////////////////////////////////////////////////////////////////
+// Has to be unsigned to avoid problems in some systems
+#define TOLOWER(c) ((char)tolower((unsigned char)(c)))
+#define ISSPACE(c) ((char)isspace((unsigned char)(c)))
+#define ISALPHA(c) ((char)isalpha((unsigned char)(c)))
+
 #endif /* _CBASETYPES_H_ */

+ 3 - 3
src/map/map.h

@@ -176,7 +176,7 @@ enum {
 //This stackable implementation does not means a BL can be more than one type at a time, but it's 
 //meant to make it easier to check for multiple types at a time on invocations such as
 // map_foreach* calls [Skotlex]
-enum { 
+enum bl_type { 
 	BL_NUL = 0x000,
 	BL_PC = 0x001,
 	BL_MOB = 0x002,
@@ -192,7 +192,7 @@ enum {
 #define BL_CHAR (BL_PC|BL_MOB|BL_HOM)
 #define BL_ALL 0xfff
 
-enum { WARP, SHOP, SCRIPT, MONS };
+enum bl_subtype { WARP, SHOP, SCRIPT, MONS };
 
 enum {
 	RC_FORMLESS=0,
@@ -1073,7 +1073,7 @@ struct map_data {
 	int water_height;
 	int npc_num;
 	int users;
-	struct {
+	struct map_flag {
 		unsigned alias : 1;
 		unsigned nomemo : 1;
 		unsigned noteleport : 1;

+ 4 - 4
src/map/npc.c

@@ -1361,7 +1361,7 @@ int npc_selllist(struct map_session_data *sd,int n,unsigned short *item_list)
 	return 0;
 }
 
-int npc_remove_map (struct npc_data *nd)
+int npc_remove_map(struct npc_data *nd)
 {
 	int m,i;
 	nullpo_retr(1, nd);
@@ -1431,11 +1431,11 @@ void npc_unload_duplicates (struct npc_data *nd)
 	map_foreachiddb(npc_unload_dup_sub,nd->bl.id);
 }
 
-int npc_unload (struct npc_data *nd)
+int npc_unload(struct npc_data *nd)
 {
 	nullpo_ret(nd);
 
-	npc_remove_map (nd);
+	npc_remove_map(nd);
 	map_deliddb(&nd->bl);
 
 	if (nd->chat_id) {
@@ -2943,7 +2943,7 @@ int do_final_npc(void)
 		if ((bl = map_id2bl(i))){
 			if (bl->type == BL_NPC)
 				npc_unload((struct npc_data *)bl);
-			else if (bl->type&(BL_MOB|BL_PET))
+			else if (bl->type&(BL_MOB|BL_PET))//## why BL_PET? [FlavioJS]
 				unit_free(bl, 0);
 		}
 	}

File diff suppressed because it is too large
+ 187 - 202
src/map/script.c


+ 2 - 2
src/map/script.h

@@ -31,7 +31,7 @@ extern struct Script_Config {
 
 struct script_data {
 	int type;
-	union {
+	union script_data_val {
 		int num;
 		char *str;
 	} u;
@@ -61,7 +61,7 @@ struct script_state {
 	} sleep;
 };
 
-struct script_code* parse_script(unsigned char *,const char*,int);
+struct script_code* parse_script(const char* src,const char* file,int line);
 void run_script_sub(struct script_code *rootscript,int pos,int rid,int oid, char* file, int lineno);
 void run_script(struct script_code*,int,int,int);
 

+ 52 - 51
src/plugins/Makefile

@@ -1,51 +1,52 @@
-
-OBJECTS = sample.dll sig.dll pid.dll gui.dll upnp.dll httpd.dll
-
-ifdef CYGWIN
-   PLUGINEXT = dll
-else
-   PLUGINEXT = so
-endif
-
-PLUGINS = $(OBJECTS:%.dll=%.$(PLUGINEXT))
-COMMON_H = ../common/plugin.h
-
-txt sql all: $(PLUGINS)
-
-%.$(PLUGINEXT): %.c
-	$(CC) $(CFLAGS) -shared -o ../../plugins/$@ $<
-	@touch $@
-
-httpd.$(PLUGINEXT): httpd.c
-	$(CC) $(CFLAGS) -shared -o ../../plugins/$@ $< \
-	../common/obj/minimalloc.o ../common/obj/db.o ../common/obj/showmsg.o \
-	../common/obj/utils.o ../common/obj/ers.o
-	@touch $@
-
-sig.$(PLUGINEXT): sig.c
-	$(CC) $(CFLAGS) -shared -o ../../plugins/$@ $< \
-	../common/obj/showmsg.o
-	@touch $@
-
-gui.$(PLUGINEXT): ../../plugins/gui.conf
-httpd.$(PLUGINEXT): ../../plugins/httpd.conf
-upnp.$(PLUGINEXT): ../../plugins/upnp.conf
-
-../../plugins/%.conf: %.txt
-	cp -r $< $@
-
-../../plugins/gui.conf: gui.txt
-../../plugins/httpd.conf: httpd.txt
-../../plugins/upnp.conf: upnp.txt
-
-depend:
-	makedepend -fGNUmakefile -o.$(PLUGINEXT) -Y. -Y../common *.c
-clean:
-	rm -rf $(PLUGINS)
-
-# DO NOT DELETE
-
-sample.$(PLUGINEXT): sample.c $(COMMON_H)
-sig.$(PLUGINEXT): sig.c $(COMMON_H)
-pid.$(PLUGINEXT): pid.c $(COMMON_H)
-gui.$(PLUGINEXT): gui.c $(COMMON_H)
+
+OBJECTS = sample.dll sig.dll pid.dll gui.dll upnp.dll httpd.dll
+
+ifdef CYGWIN
+   PLUGINEXT = dll
+else
+   PLUGINEXT = so
+endif
+
+PLUGINS = $(OBJECTS:%.dll=%.$(PLUGINEXT))
+COMMON_H = ../common/plugin.h
+
+txt sql all: $(PLUGINS)
+
+%.$(PLUGINEXT): %.c
+	$(CC) $(CFLAGS) -shared -o ../../plugins/$@ $<
+	@touch $@
+
+httpd.$(PLUGINEXT): httpd.c
+	$(CC) $(CFLAGS) -shared -o ../../plugins/$@ $< \
+	../common/obj/minimalloc.o ../common/obj/db.o ../common/obj/showmsg.o \
+	../common/obj/utils.o ../common/obj/ers.o
+	@touch $@
+
+sig.$(PLUGINEXT): sig.c
+	$(CC) $(CFLAGS) -shared -o ../../plugins/$@ $< \
+	../common/obj/showmsg.o ../common/obj/utils.o \
+	../common/obj/minimalloc.o
+	@touch $@
+
+gui.$(PLUGINEXT): ../../plugins/gui.conf
+httpd.$(PLUGINEXT): ../../plugins/httpd.conf
+upnp.$(PLUGINEXT): ../../plugins/upnp.conf
+
+../../plugins/%.conf: %.txt
+	cp -r $< $@
+
+../../plugins/gui.conf: gui.txt
+../../plugins/httpd.conf: httpd.txt
+../../plugins/upnp.conf: upnp.txt
+
+depend:
+	makedepend -fGNUmakefile -o.$(PLUGINEXT) -Y. -Y../common *.c
+clean:
+	rm -rf $(PLUGINS)
+
+# DO NOT DELETE
+
+sample.$(PLUGINEXT): sample.c $(COMMON_H)
+sig.$(PLUGINEXT): sig.c $(COMMON_H)
+pid.$(PLUGINEXT): pid.c $(COMMON_H)
+gui.$(PLUGINEXT): gui.c $(COMMON_H)

Some files were not shown because too many files changed in this diff