Last night my friend sent these src to me and he said that he want to use it but when he compile these code it got many error then he told me to help him but I know nothing about src so I want to ask you all anybody know how to fix it until it can be use ?
Index: atcommand.c
===================================================================
--- atcommand.c (revision 2809)
+++ atcommand.c (working copy)
@@ -3542,13 +3542,13 @@
*------------------------------------------*/
ACMD_FUNC(reload)
{
- const char *opt[] = { "item_db", "mob_db", "skill_db", "status_db", "pc_db", "groups", "quest_db", "homunculus_db", "pet_db", "motd", "cashshop", "buffspecial" };
+ const char *opt[] = { "item_db", "mob_db", "skill_db", "status_db", "pc_db", "groups", "quest_db", "homunculus_db", "pet_db", "motd", "cashshop", "buffspecial", "folder" };
int option;
memset(atcmd_output, '\0', sizeof(atcmd_output));
if(!message || !*message) {
- clif_displaymessage(fd, "Op็๕es: item_db, mob_db, skill_db, status_db, pc_db, groups, quest_db, homunculus_db, pet_db, motd, cashshop & buffspecial");
+ clif_displaymessage(fd, "Op็๕es: item_db, mob_db, skill_db, status_db, pc_db, groups, quest_db, homunculus_db, pet_db, motd, folder, cashshop & buffspecial");
clif_displaymessage(fd, "Modo de uso: @reload <op็ใo>");
return false;
}
@@ -3672,7 +3672,14 @@
clif_displaymessage(fd, msg_txt(255));
return true;
}
-
+int check_npc_folder(char * path){
+ folder * aux;
+ for(aux=ptr;aux!=NULL;aux=aux->next){
+ if(strcmp(aux->name+4,path)==0)
+ return 1;
+ }
+ return 0;
+}
/*==========================================
* @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...)
*------------------------------------------*/
@@ -3714,6 +3721,34 @@
return true;
}
+ACMD_FUNC(reloadfolder)
+{
+ char npc_choice[100];
+ int v_type=0;
+ folder * aux;
+ char npc_path[100];
+
+ if(!message || !*message || sscanf(message, "%s",npc_choice) < 1) {
+ clif_displaymessage(fd,"Como usar: <pasta> - Reload de NPCs presentes na pasta." );
+ for(aux=ptr;aux!=NULL;aux=aux->next){
+ clif_displaymessage(fd,aux->name+4);
+ }
+ clif_displaymessage(fd,"reloadfolder - Por favor especifique uma op็ใo.");
+ }
+ else if(check_npc_folder(npc_choice)){
+ sprintf(npc_path,"npc/%s",npc_choice);
+ if(npc->reload_folder(npc_path))
+ return false;
+ else{
+ clif_displaymessage(fd,"Scripts Recarregados.");
+ return true;
+ }
+ }
+ else return false;
+
+ return true;
+}
+
/*==========================================
* @mapinfo [0-3] <map name> by MC_Cameri
* => Shows information about the map [map name]
@@ -9603,6 +9638,7 @@
ACMD_DEF(localbroadcast), // + /lb and /nlb
ACMD_DEF(recallall),
ACMD_DEF(reloadscript),
+ ACMD_DEF(reloadfolder),
ACMD_DEF(reloadatcommand),
ACMD_DEF(reloadbattleconf),
ACMD_DEF(mapinfo),
Index: map.c
===================================================================
--- map.c (revision 2809)
+++ map.c (working copy)
@@ -5503,6 +5503,19 @@
SERVER_TYPE = SERVER_TYPE_MAP;
}
+// Free Folder LList
+void free_folder(folder * ptr)
+{
+ folder * aux, * aux2;
+ aux=ptr;
+ while(aux!=NULL){
+ aux2=aux;
+ aux=aux->next;
+ free(aux2->name);
+ free(aux2);
+ }
+ return;
+}
/// Called when a terminate signal is received.
void do_shutdown(void)
@@ -5513,15 +5526,18 @@
{
struct map_session_data *sd;
struct s_mapiterator *iter = mapit_getallusers();
+ free_folder(ptr);
for(sd = (TBL_PC *)mapit_first(iter); mapit->exists(iter); sd = (TBL_PC *)mapit_next(iter))
clif_GM_kick(NULL, sd);
mapit->free(iter);
flush_fifos();
+
}
chrif->check_shutdown();
}
}
+
bool map_arg_next_value(const char* option, int i, int argc, bool must)
{
if(i >= argc-1) {
Index: map.h
===================================================================
--- map.h (revision 2809)
+++ map.h (working copy)
@@ -29,6 +29,7 @@
#include <stdarg.h>
+
struct npc_data;
struct item_data;
struct raChSysCh;
@@ -325,6 +326,13 @@
ATF_MISC=0x40,
};
+typedef struct _folder{
+ struct _folder * next;
+ char * name;
+} folder;
+folder * npc_new_folder(size_t size,folder * ptr,const char * filepath);
+folder * ptr;
+
struct block_list {
struct block_list *next,*prev;
int id;
Index: npc.c
===================================================================
--- npc.c (revision 2809)
+++ npc.c (working copy)
@@ -2165,7 +2165,7 @@
nullpo_ret(nd);
- npc->remove_map(nd);
+ npc->remove_map(nd);
map->deliddb(&nd->bl);
if(single)
strdb_remove(npc->name_db, nd->exname);
@@ -2188,7 +2188,7 @@
aFree(nd->path);/* remove now that no other instances exist */
}
}
-
+///
if(single && nd->bl.m != -1)
map->remove_questinfo(nd->bl.m,nd);
@@ -2973,6 +2973,7 @@
nd->src_id = src_id;
nd->bl.type = BL_NPC;
nd->subtype = (enum npc_subtype)type;
+
switch(type) {
case SCRIPT:
++npc_script;
@@ -3908,7 +3909,20 @@
return strchr(start,'\n');// continue
}
-
+folder * npc_new_folder(size_t size,folder * ptr, const char * filepath){
+ folder * new;
+ int i;
+ new= (struct _folder*) malloc(sizeof(struct _folder));
+ for(i=4;filepath[i]!='/';i++);
+ if(filepath[i]!='/')
+ return ptr;
+ new->name= (char*) malloc(sizeof(char)*(i+1));
+ strncpy(new->name,filepath,i);
+ new->name[i]='\0';
+ new->next = ptr;
+
+ return new;
+}
//Read file and create npc/func/mapflag/monster... accordingly.
//@runOnInit should we exec OnInit when it's done ?
int npc_parsesrcfile(const char *filepath, bool runOnInit)
@@ -3919,7 +3933,26 @@
size_t len;
char *buffer;
const char *p;
-
+ int has_folder = 0;
+ static folder * aux;
+
+ if(ptr==NULL)
+ ptr = npc_new_folder(sizeof(filepath),ptr,filepath) ;
+
+ //Folder Information - [GreenStage]
+ //Check if NPC belongs to an existing folder
+ for(aux=ptr;aux!=NULL;aux=aux->next){
+ if(strncmp(filepath,aux->name,strlen(aux->name))==0){
+ has_folder=1;
+
+ break;
+ }
+ }
+ //NPC seems to belong to a new folder, add folder info.
+ if(!has_folder){
+ ptr=npc_new_folder(sizeof(filepath),ptr,filepath);
+ ShowNpc("Pasta Encontrada: %s \n",ptr->name);
+ }
// read whole file to buffer
fp = fopen(filepath, "rb");
if(fp == NULL) {
@@ -4223,7 +4256,6 @@
linkdb_final(label_linkdb); // linked data (struct event_data*) is freed when clearing npc->ev_db
return 0;
}
-
//Clear then reload npcs files
int npc_reload(void)
{
@@ -4328,6 +4360,33 @@
return 0;
}
+int npc_reload_folder(char * folder_path)
+{
+ struct npc_src_list *nsl;
+ DBIterator *iter = db_iterator(npc->name_db);
+ struct npc_data *nd = NULL;
+ unsigned int count=0;
+
+ for(nd = dbi_first(iter); dbi_exists(iter); nd = dbi_next(iter)) {
+ if(nd->path && strncmp(nd->path,folder_path,strlen(folder_path)) == 0) {
+ npc->unload_duplicates(nd);/* unload any npcs which could duplicate this but be in a different file */
+ npc->unload(nd, true);
+ }
+ }
+ dbi_destroy(iter);
+
+ for(nsl = npc->src_files; nsl; nsl = nsl->next) {
+ if(strncmp(nsl->name,folder_path,strlen(folder_path))==0){
+ count++;
+ ShowNpc("Carregando arquivo de NPC: %s"CL_CLL"\r", nsl->name);
+ npc->parsesrcfile(nsl->name,false);
+ }
+ }
+ /* refresh event cache */
+ npc->read_event_script();
+ ShowNpc("'"CL_WHITE"%d"CL_RESET"' arquivos na pasta '"CL_WHITE"%s"CL_RESET"' recarregados\n",count,folder_path);
+ return 0;
+}
//Unload all npc in the given file
bool npc_unloadfile(const char *filepath)
{
@@ -4591,6 +4650,7 @@
npc->path_db_clear_sub = npc_path_db_clear_sub;
npc->ev_label_db_clear_sub = npc_ev_label_db_clear_sub;
npc->reload = npc_reload;
+ npc->reload_folder = npc_reload_folder;
npc->unloadfile = npc_unloadfile;
npc->do_clear_npc = do_clear_npc;
npc->debug_warps_sub = npc_debug_warps_sub;
Index: npc.h
===================================================================
--- npc.h (revision 2809)
+++ npc.h (working copy)
@@ -265,6 +265,7 @@
int (*path_db_clear_sub) (DBKey key, DBData *data, va_list args);
int (*ev_label_db_clear_sub) (DBKey key, DBData *data, va_list args);
int (*reload) (void);
+ int (*reload_folder) (char * folder_path);
bool (*unloadfile) (const char *filepath);
void (*do_clear_npc) (void);
void (*debug_warps_sub) (struct npc_data *nd);