Removed 'petid', a command from r284 to look up pet ids by name.
Cleaned up some pet-related code. git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@11586 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
parent
2cb8a5838e
commit
0031c1553e
@ -4,6 +4,7 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO
|
|||||||
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
|
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
|
||||||
|
|
||||||
2007/10/27
|
2007/10/27
|
||||||
|
* Removed 'petid', a command from r284 to look up pet ids by name
|
||||||
* Fixed TXT charserver doing periodic random-sized alloc (bugreport:312)
|
* Fixed TXT charserver doing periodic random-sized alloc (bugreport:312)
|
||||||
* Set 'Create Converter's produce success rate to 100% (bugreport:302)
|
* Set 'Create Converter's produce success rate to 100% (bugreport:302)
|
||||||
* Added check that verifies weapon/ammo/state requirements also when
|
* Added check that verifies weapon/ammo/state requirements also when
|
||||||
|
@ -201,7 +201,6 @@ ACMD_FUNC(uptime); // by MC Cameri
|
|||||||
ACMD_FUNC(changesex); // by MC Cameri
|
ACMD_FUNC(changesex); // by MC Cameri
|
||||||
ACMD_FUNC(mute); // celest
|
ACMD_FUNC(mute); // celest
|
||||||
ACMD_FUNC(refresh); // by MC Cameri
|
ACMD_FUNC(refresh); // by MC Cameri
|
||||||
ACMD_FUNC(petid); // by MC Cameri
|
|
||||||
ACMD_FUNC(identify); // by MC Cameri
|
ACMD_FUNC(identify); // by MC Cameri
|
||||||
ACMD_FUNC(gmotd); // Added by MC Cameri, created by davidsiaw
|
ACMD_FUNC(gmotd); // Added by MC Cameri, created by davidsiaw
|
||||||
ACMD_FUNC(misceffect); // by MC Cameri
|
ACMD_FUNC(misceffect); // by MC Cameri
|
||||||
@ -486,7 +485,6 @@ static AtCommandInfo atcommand_info[] = {
|
|||||||
{ AtCommand_Mute, "@mute", 80, atcommand_mute }, // [celest]
|
{ AtCommand_Mute, "@mute", 80, atcommand_mute }, // [celest]
|
||||||
{ AtCommand_WhoZeny, "@whozeny", 20, atcommand_whozeny }, // [Valaris]
|
{ AtCommand_WhoZeny, "@whozeny", 20, atcommand_whozeny }, // [Valaris]
|
||||||
{ AtCommand_Refresh, "@refresh", 1, atcommand_refresh }, // by MC Cameri
|
{ AtCommand_Refresh, "@refresh", 1, atcommand_refresh }, // by MC Cameri
|
||||||
{ AtCommand_PetId, "@petid", 40, atcommand_petid }, // by MC Cameri
|
|
||||||
{ AtCommand_Identify, "@identify", 40, atcommand_identify }, // by MC Cameri
|
{ AtCommand_Identify, "@identify", 40, atcommand_identify }, // by MC Cameri
|
||||||
{ AtCommand_Gmotd, "@gmotd", 20, atcommand_gmotd }, // Added by MC Cameri, created by davidsiaw
|
{ AtCommand_Gmotd, "@gmotd", 20, atcommand_gmotd }, // Added by MC Cameri, created by davidsiaw
|
||||||
{ AtCommand_MiscEffect, "@misceffect", 50, atcommand_misceffect }, // by MC Cameri
|
{ AtCommand_MiscEffect, "@misceffect", 50, atcommand_misceffect }, // by MC Cameri
|
||||||
@ -7591,44 +7589,6 @@ int atcommand_refresh(const int fd, struct map_session_data* sd, const char* com
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================
|
|
||||||
* @petid <part of pet name>
|
|
||||||
* => Displays a list of matching pets.
|
|
||||||
*------------------------------------------*/
|
|
||||||
int atcommand_petid(const int fd, struct map_session_data* sd, const char* command, const char* message)
|
|
||||||
{
|
|
||||||
char searchtext[100];
|
|
||||||
char temp0[100];
|
|
||||||
int cnt = 0, i = 0;
|
|
||||||
|
|
||||||
nullpo_retr(-1, sd);
|
|
||||||
|
|
||||||
if (!message || !*message || sscanf(message, "%99s", searchtext) < 1)
|
|
||||||
{
|
|
||||||
clif_displaymessage(fd, "Please, enter a pet name (usage: @petid <part of pet name>).");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
snprintf(temp0, sizeof(temp0), "First %i search results for: %s", MAX_SEARCH, searchtext);
|
|
||||||
clif_displaymessage(fd,temp0);
|
|
||||||
|
|
||||||
for (i = 0; i < MAX_PET_DB; i++)
|
|
||||||
{
|
|
||||||
if (stristr(pet_db[i].name, searchtext) || stristr(pet_db[i].jname, searchtext))
|
|
||||||
{
|
|
||||||
cnt++;
|
|
||||||
if (cnt <= MAX_SEARCH) { // limits the number of search results
|
|
||||||
snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class_, pet_db[i].jname);
|
|
||||||
clif_displaymessage(fd, temp0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
snprintf(temp0, sizeof(temp0), "%i pets have '%s' in their name.", cnt, searchtext);
|
|
||||||
clif_displaymessage(fd, temp0);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*==========================================
|
/*==========================================
|
||||||
* @identify
|
* @identify
|
||||||
* => GM's magnifier.
|
* => GM's magnifier.
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "../common/nullpo.h"
|
#include "../common/nullpo.h"
|
||||||
#include "../common/malloc.h"
|
#include "../common/malloc.h"
|
||||||
#include "../common/showmsg.h"
|
#include "../common/showmsg.h"
|
||||||
|
#include "../common/strlib.h"
|
||||||
#include "../common/utils.h"
|
#include "../common/utils.h"
|
||||||
#include "../common/ers.h"
|
#include "../common/ers.h"
|
||||||
|
|
||||||
@ -23,7 +24,7 @@
|
|||||||
#include "script.h"
|
#include "script.h"
|
||||||
#include "skill.h"
|
#include "skill.h"
|
||||||
#include "unit.h"
|
#include "unit.h"
|
||||||
#include "atcommand.h"
|
#include "atcommand.h" // msg_txt()
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -279,30 +280,16 @@ int search_petDB_index(int key,int type)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i=0;i<MAX_PET_DB;i++) {
|
for( i = 0; i < MAX_PET_DB; i++ )
|
||||||
|
{
|
||||||
if(pet_db[i].class_ <= 0)
|
if(pet_db[i].class_ <= 0)
|
||||||
continue;
|
continue;
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case PET_CLASS:
|
case PET_CLASS: if(pet_db[i].class_ == key) return i; break;
|
||||||
if(pet_db[i].class_ == key)
|
case PET_CATCH: if(pet_db[i].itemID == key) return i; break;
|
||||||
return i;
|
case PET_EGG: if(pet_db[i].EggID == key) return i; break;
|
||||||
break;
|
case PET_EQUIP: if(pet_db[i].AcceID == key) return i; break;
|
||||||
case PET_CATCH:
|
case PET_FOOD: if(pet_db[i].FoodID == key) return i; break;
|
||||||
if(pet_db[i].itemID == key)
|
|
||||||
return i;
|
|
||||||
break;
|
|
||||||
case PET_EGG:
|
|
||||||
if(pet_db[i].EggID == key)
|
|
||||||
return i;
|
|
||||||
break;
|
|
||||||
case PET_EQUIP:
|
|
||||||
if(pet_db[i].AcceID == key)
|
|
||||||
return i;
|
|
||||||
break;
|
|
||||||
case PET_FOOD:
|
|
||||||
if(pet_db[i].FoodID == key)
|
|
||||||
return i;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1252,40 +1239,46 @@ int pet_skill_support_timer(int tid,unsigned int tick,int id,int data)
|
|||||||
*------------------------------------------*/
|
*------------------------------------------*/
|
||||||
int read_petdb()
|
int read_petdb()
|
||||||
{
|
{
|
||||||
|
char* filename[] = {"pet_db.txt","pet_db2.txt"};
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char line[1024];
|
int nameid,i,j,k;
|
||||||
int nameid,i,k;
|
|
||||||
int j=0;
|
|
||||||
int lines;
|
|
||||||
char *filename[]={"pet_db.txt","pet_db2.txt"};
|
|
||||||
char *str[32],*p,*np;
|
|
||||||
|
|
||||||
|
// Remove any previous scripts in case reloaddb was invoked.
|
||||||
//Remove any previous scripts in case reloaddb was invoked.
|
for( j = 0; j < MAX_PET_DB; j++ )
|
||||||
for(j =0; j < MAX_PET_DB; j++)
|
|
||||||
if (pet_db[j].script) {
|
if (pet_db[j].script) {
|
||||||
aFree(pet_db[j].script);
|
aFree(pet_db[j].script);
|
||||||
pet_db[j].script = NULL;
|
pet_db[j].script = NULL;
|
||||||
}
|
}
|
||||||
j = 0;
|
|
||||||
|
// clear database
|
||||||
memset(pet_db,0,sizeof(pet_db));
|
memset(pet_db,0,sizeof(pet_db));
|
||||||
for(i=0;i<2;i++){
|
|
||||||
|
j = 0; // entry counter
|
||||||
|
for( i = 0; i < ARRAYLENGTH(filename); i++ )
|
||||||
|
{
|
||||||
|
char line[1024];
|
||||||
|
int lines;
|
||||||
|
|
||||||
sprintf(line, "%s/%s", db_path, filename[i]);
|
sprintf(line, "%s/%s", db_path, filename[i]);
|
||||||
fp=fopen(line,"r");
|
fp=fopen(line,"r");
|
||||||
if(fp==NULL){
|
if( fp == NULL )
|
||||||
if(i>0)
|
|
||||||
continue;
|
|
||||||
ShowError("can't read %s\n",line);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
lines = 0;
|
|
||||||
while(fgets(line, sizeof(line), fp) && j < MAX_PET_DB)
|
|
||||||
{
|
{
|
||||||
|
if( i == 0 )
|
||||||
|
ShowError("can't read %s\n",line);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
lines = 0;
|
||||||
|
while( fgets(line, sizeof(line), fp) && j < MAX_PET_DB )
|
||||||
|
{
|
||||||
|
char *str[32],*p,*np;
|
||||||
|
|
||||||
lines++;
|
lines++;
|
||||||
|
|
||||||
if(line[0] == '/' && line[1] == '/')
|
if(line[0] == '/' && line[1] == '/')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// split string into table columns
|
||||||
for(k=0,p=line;k<20;k++){
|
for(k=0,p=line;k<20;k++){
|
||||||
if((np=strchr(p,','))!=NULL){
|
if((np=strchr(p,','))!=NULL){
|
||||||
str[k]=p;
|
str[k]=p;
|
||||||
@ -1307,8 +1300,8 @@ int read_petdb()
|
|||||||
}
|
}
|
||||||
|
|
||||||
pet_db[j].class_ = nameid;
|
pet_db[j].class_ = nameid;
|
||||||
strncpy(pet_db[j].name,str[1],NAME_LENGTH);
|
safestrncpy(pet_db[j].name,str[1],NAME_LENGTH);
|
||||||
strncpy(pet_db[j].jname,str[2],NAME_LENGTH);
|
safestrncpy(pet_db[j].jname,str[2],NAME_LENGTH);
|
||||||
pet_db[j].itemID=atoi(str[3]);
|
pet_db[j].itemID=atoi(str[3]);
|
||||||
pet_db[j].EggID=atoi(str[4]);
|
pet_db[j].EggID=atoi(str[4]);
|
||||||
pet_db[j].AcceID=atoi(str[5]);
|
pet_db[j].AcceID=atoi(str[5]);
|
||||||
@ -1334,7 +1327,8 @@ int read_petdb()
|
|||||||
pet_db[j].script = parse_script(np, filename[i], lines, 0);
|
pet_db[j].script = parse_script(np, filename[i], lines, 0);
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
if (j >= MAX_PET_DB)
|
|
||||||
|
if( j >= MAX_PET_DB )
|
||||||
ShowWarning("read_petdb: Reached max number of pets [%d]. Remaining pets were not read.\n ", MAX_PET_DB);
|
ShowWarning("read_petdb: Reached max number of pets [%d]. Remaining pets were not read.\n ", MAX_PET_DB);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' pets in '"CL_WHITE"%s"CL_RESET"'.\n",j,filename[i]);
|
ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' pets in '"CL_WHITE"%s"CL_RESET"'.\n",j,filename[i]);
|
||||||
@ -1367,7 +1361,7 @@ int do_init_pet(void)
|
|||||||
|
|
||||||
int do_final_pet(void) {
|
int do_final_pet(void) {
|
||||||
int i;
|
int i;
|
||||||
for(i = 0;i < MAX_PET_DB; i++) {
|
for( i = 0; i < MAX_PET_DB; i++ ) {
|
||||||
if(pet_db[i].script) {
|
if(pet_db[i].script) {
|
||||||
script_free_code(pet_db[i].script);
|
script_free_code(pet_db[i].script);
|
||||||
pet_db[i].script = NULL;
|
pet_db[i].script = NULL;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#define _PET_H_
|
#define _PET_H_
|
||||||
|
|
||||||
#define MAX_PET_DB 300
|
#define MAX_PET_DB 300
|
||||||
#define MAX_PETLOOT_SIZE 30 // [Valaris] - Changed to MAX_PETLOOT_SIZE [Skotlex]
|
#define MAX_PETLOOT_SIZE 30
|
||||||
|
|
||||||
struct s_pet_db {
|
struct s_pet_db {
|
||||||
short class_;
|
short class_;
|
||||||
|
@ -3772,12 +3772,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
|
|||||||
case SA_TAMINGMONSTER:
|
case SA_TAMINGMONSTER:
|
||||||
clif_skill_nodamage(src,bl,skillid,skilllv,1);
|
clif_skill_nodamage(src,bl,skillid,skilllv,1);
|
||||||
if (sd && dstmd) {
|
if (sd && dstmd) {
|
||||||
for (i = 0; i < MAX_PET_DB; i++) {
|
ARR_FIND( 0, MAX_PET_DB, i, dstmd->class_ == pet_db[i].class_ );
|
||||||
if (dstmd->class_ == pet_db[i].class_) {
|
if( i < MAX_PET_DB )
|
||||||
pet_catch_process1 (sd, dstmd->class_);
|
pet_catch_process1(sd, dstmd->class_);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user