/*! \author Luxor */ void cChar::follow( pChar pc ) { if ( isFrozen() ) { if ( hasPath() ) safedelete( path ); return; } if ( dist( getBody()->getPosition(), pc->getBody()->getPosition() ) <= 1.0 ) { // Target reached if ( hasPath() ) safedelete( path ); facexy( pc->getBody()->getPosition().x, pc->getBody()->getPosition().y ); return; } if ( !hasPath() || path->targetReached() ) { // We haven't got a right path, call the pathfinding. pathFind( pc->getBody()->getPosition(), true ); walkNextStep(); return; } double distance = dist( path->getFinalPos(), pc->getBody()->getPosition() ); if ( distance <= 3.0 ) { // Path finalPos is pretty near... let's not overhead the processor walkNextStep(); } else { // Path finalPos is too far, call the pathfinding. pathFind( pc->getBody()->getPosition(), true ); walkNextStep(); } }
std::string cObject::getRandomScriptValue( std::string section, std::string& sectionId ) { std::string script1; int i = 0, j = 0; std::string value; cScpIterator* iter = getScriptIterator( section, sectionId ); if (iter == 0) { WarnOut("SECTION %s %s not found\n", section.c_str(), sectionId.c_str() ); } else { int loopexit=0; do { script1 = iter->getEntry()->getFullLine(); if ( script1[0]!='}' && script1[0]!='{' ) { ++i; } } while ( script1[0] !='}' && ++loopexit < MAXLOOPS ); safedelete(iter); if(i>0) { i=rand()%i; iter = getScriptIterator( section, sectionId ); if (iter == 0) { WarnOut("SECTION %s %s not found\n", section.c_str(), sectionId.c_str() ); } else { loopexit=0; do { script1 = iter->getEntry()->getFullLine(); if ( script1[0]!='}' && script1[0]!='{' ) { if(j==i) { value = script1; // Wintermute stop going through the whole loop break; } ++j; } } while ( script1[0]!='}' && ++loopexit < MAXLOOPS ); safedelete(iter); } } } return value; }
cObject::~cObject() { if ( tempfx ) { tempfx->clear(); safedelete( tempfx ); } if( disabledmsg!=NULL ) safedelete( disabledmsg ); }
SI32 cAccounts::verifyPassword(std::string username, std::string password) { ACCOUNT_LIST_BY_NAME::iterator iter_account_by_name(this->accbyname.find(username)); if (iter_account_by_name != this->accbyname.end()) { ACCOUNT_LIST::iterator iter_account( this->acctlist.find(iter_account_by_name->second) ); if( iter_account==this->acctlist.end() ) return LOGIN_NOT_FOUND; if ((iter_account->second.pass[0])=='!') { //these are encrypted passwords!!! char str[100]; strcpy(str,password.c_str()); char *pwd = pwdcypher(str, (iter_account->second.pass[1])-'A'); if (pwd==NULL) return LOGIN_NOT_FOUND; str[0] = '!'; str[1] = '\0'; strcat(str,pwd); safedelete(pwd); //xan : avoid a repetitive memory leak :) password.erase(); password = str; //someone with a bit of knowledge about STL strings.. plz chg this! } if( iter_account->second.pass != password ) { return BAD_PASSWORD; } } return 0; }
/*! \brief Check if the user can use the RAS ( Remote Admin System ) \return true if can, false else \param username Username \param password Password \remarks Always the Account n° 0 can use Ras */ bool cAccounts::AuthenticateRAS(std::string username, std::string password) { ACCOUNT_LIST_BY_NAME::iterator iter_account_by_name(this->accbyname.find(username)); if (iter_account_by_name != this->accbyname.end()) { ACCOUNT_LIST::iterator iter_account( this->acctlist.find(iter_account_by_name->second) ); if( iter_account==this->acctlist.end() ) return false; if ((iter_account->second.pass.c_str())[0]=='!') { //these are encrypted passwords!!! char str[100]; strcpy(str,password.c_str()); char *pwd = pwdcypher(str, (iter_account->second.pass.c_str())[1]-'A'); if (pwd==NULL) return false; str[0] = '!'; str[1] = '\0'; strcat(str,pwd); safedelete(pwd); //xan : avoid a repetitive memory leak :) password.erase(); password = str; //someone with a bit of knowledge about STL strings.. plz chg this! } if( iter_account->second.pass == password ) { if( iter_account->second.ban ) return false; else return (iter_account->second.ras)||(iter_account->second.number==ADMIN_ACCOUNT); } else return false; } else return false; }
void cBasicMenu::setCallBack( int fn ) { if( callback!=NULL ) safedelete( callback ); callback = new AmxFunction( fn ); }
void cBasicMenu::setCallBack( string arg ) { if( callback!=NULL ) safedelete( callback ); callback = new AmxFunction( const_cast< char* >( arg.c_str() ) ); }
/*! \brief Create a new account \return ACCOUNT the account id or INVALID if not created \param username Username \param password Password */ ACCOUNT cAccounts::CreateAccount(std::string username, std::string password) { lastusedacctnum++; if ( accbyname.count(username) ) // if there's another account with this name.. return INVALID; if (ServerScp::g_nUseAccountEncryption) { //xan : for account DES encryption :) char str[1000]; strcpy(str,password.c_str()); char *pwd = pwdcypher(str, -1); if (pwd!=NULL) { //if pwd fails (any reason) use unencrypted pwd! :) str[0] = '!'; str[1] = '\0'; strcat(str,pwd); safedelete(pwd); //xan : avoid a repetitive memory leak :) password.erase(); password = str; //someone with a bit of knowledge about STL strings.. plz chg this! } } cAccount account(lastusedacctnum); account.name = username; account.pass = password; safeInsert( account ); unsavedaccounts++; if (unsavedaccounts >= saveratio) SaveAccounts(); return account.number; }
/*! \author Luxor */ void cChar::walkNextStep() { if ( isFrozen() ) return; if ( !hasPath() ) return; if ( !path->pathFound() ) path->exec(); sLocation pos = path->getNextPos(); if ( pos == getPosition() ) return; if ( isWalkable( pos, WALKFLAG_DYNAMIC|WALKFLAG_CHARS, this ) == illegal_z ) { safedelete( path ); return; } pCreatureInfo creature = creatures.getCreature( getId() ); if( creature!=NULL ) { if( creature->canFly() && ( fly_steps>0 ) ) if ( chance( 20 ) ) playAction( 0x13 ); // Flying animation } uint8_t dirXY = getDirFromXY(pos); dir = dirXY & 0x07; MoveTo( pos ); sendToPlayers( this, dirXY ); setNpcMoveTime(); }
void offlinehtml()//HTML { char sect[512], hfile[512],time_str[80]; unsigned int total,hr,min,sec,loopexit=0; //bugfix LB FILE *html; total=(uiCurrentTime-starttime)/MY_CLOCKS_PER_SEC; hr=total/3600; total-=hr*3600; min=total/60; total-=min*60; sec=total; cScpIterator* iter = NULL; char script1[1024]; char script2[1024]; strcpy(sect,"SECTION OFFLINE"); iter = Scripts::HtmlStrm->getNewIterator(sect); if (iter==NULL) return; strcpy(script1, iter->getEntry()->getFullLine().c_str()); //discard { strcpy(script1, iter->getEntry()->getFullLine().c_str()); strcpy(hfile, script1); html = fopen(hfile, "w"); if (html == NULL) // LB { WarnOut("Could not create html file, plz check html.xss\n"); safedelete(iter); return; } do { iter->parseLine(script1, script2); if(!(strcmp(script1,"LINE"))) fprintf(html,"%s\n",script2); else if(!(strcmp(script1,"TIME"))) fprintf(html,RealTime(time_str)); else if(!(strcmp(script1,"UPTIME"))) fprintf(html,"%i:%i:%i",hr,min,sec); } while( (script1[0]!='}') && (++loopexit < MAXLOOPS) ); fclose(html); safedelete(iter); }
/*! \brief Get info about account by username and password \return account, of why not right \param username Username \param password Password */ SI32 cAccounts::Authenticate(std::string username, std::string password) { ACCOUNT_LIST_BY_NAME::iterator iter_account_by_name(this->accbyname.find(username)); if (iter_account_by_name != this->accbyname.end()) { ACCOUNT_LIST::iterator iter_account( this->acctlist.find(iter_account_by_name->second) ); if( iter_account==this->acctlist.end() ) return LOGIN_NOT_FOUND; if ((iter_account->second.pass[0])=='!') { //these are encrypted passwords!!! char str[100]; strcpy(str,password.c_str()); char *pwd = pwdcypher(str, (iter_account->second.pass[1])-'A'); if (pwd==NULL) return LOGIN_NOT_FOUND; str[0] = '!'; str[1] = '\0'; strcat(str,pwd); safedelete(pwd); //xan : avoid a repetitive memory leak :) password.erase(); password = str; //someone with a bit of knowledge about STL strings.. plz chg this! } if( iter_account->second.pass == password ) { if( iter_account->second.ban ) { InfoOut("account banned\n "); //elcabesa tempblock return ACCOUNT_BANNED; } else if( (server_data.blockaccbadpass==1) && (iter_account->second.tempblock>=server_data.n_badpass) && (iter_account->second.blockeduntil>uiCurrentTime) )//elcabesa tempblock { InfoOut("account blocked \n"); //elcabesa tempblock return BAD_PASSWORD;//elcabesa tempblock } else { iter_account->second.tempblock=0;//elcabesa tempblock iter_account->second.blockeduntil=0;//elcabesa tempblock return iter_account->second.number; } } else { if(server_data.blockaccbadpass==1) //elcabesa tempblock { //elcabesa tempblock iter_account->second.tempblock++;//elcabesa tempblock iter_account->second.blockeduntil=uiCurrentTime+MY_CLOCKS_PER_SEC*60*server_data.time_badpass;//elcabesa tempblock } //elcabesa tempblock return BAD_PASSWORD; } } else return LOGIN_NOT_FOUND; }
StreamedMesh::~StreamedMesh() { if (_vertexBufferCpuMemory) ::free(_vertexBufferCpuMemory); for (auto it = _vertexStreams.begin(); it != _vertexStreams.end(); it++) { VertexStream* stream = it->second; safedelete (stream); } _vertexStreams.clear(); }
/*! \author Luxor \brief Tells if the object has tempfx in queue */ bool cObject::hasTempfx() { if ( tempfx == NULL ) return false; if ( tempfx->empty() ) { safedelete( tempfx ); return false; } return true; }
void loadweaponsinfo() { cScpIterator* iter = NULL; char script1[1024]; char script2[1024]; SI32 id=INVALID; int type=SWORD1H; int loopexit=0; do { safedelete(iter); iter = Scripts::WeaponInfo->getNewIterator("SECTION WEAPONTYPE %i", type ); if( iter==NULL ) continue; do { iter->parseLine(script1, script2); if ((script1[0]!='}')&&(script1[0]!='{')) { if (!strcmp("ID", script1)) { id = str2num(script2); weaponinfo[id]=static_cast<WEAPONTYPE>(type); } } } while ( (script1[0]!='}') && (++loopexit < MAXLOOPS) ); type++; } while ( (strcmp("EOF", script1)) && (++loopexit < MAXLOOPS) ); safedelete(iter); }
bool ShaderD3D11::free() { for(auto it = _parameters.begin(); it != _parameters.end(); it++) { safedelete((*it)); } _parameters.erase(_parameters.begin(), _parameters.end()); for (auto it = _techniques.begin(); it != _techniques.end(); it++) { safedelete((*it)); } for (auto it = _shaderParameterValues.begin(); it != _shaderParameterValues.end(); it++) { _deviceInterface->shaderValueFactory()->removeShaderParameterValue (*it); } for (auto it = _constantBuffers.begin(); it != _constantBuffers.end(); it++) { safedelete (*it); } _shaderParameterValues.clear(); _meshParameters.clear(); _techniqueParameters.clear(); _parameters.clear(); _techniques.clear(); _constantBuffers.clear(); safedelete (_effect); safedeletearray(_compiledBuffer); return true; }
void newScriptsInit() { cScpScript* Dummy = new cScpScript("scripts/symbols.xss"); safedelete(Dummy); Scripts::Advance = new cScpScript("scripts/advance.xss"); // Scripts::Calendar = new cScpScript("calendar.scp"); Scripts::Carve = new cScpScript("scripts/carve.xss"); Scripts::Colors = new cScpScript("scripts/colors.xss"); Scripts::Create = new cScpScript("scripts/create.xss"); // Scripts::CronTab = new cScpScript("crontab.scp"); Scripts::Envoke = new cScpScript("scripts/envoke.xss"); Scripts::Fishing = new cScpScript("scripts/fishing.xss"); Scripts::HardItems = new cScpScript("scripts/harditems.xss"); Scripts::House = new cScpScript("scripts/house.xss"); Scripts::Creatures = new cScpScript("scripts/creatures.xss"); Scripts::HostDeny = new cScpScript("config/hostdeny.xss"); Scripts::HtmlStrm = new cScpScript("scripts/html.xss"); Scripts::Items = new cScpScript("scripts/items.xss"); Scripts::Location = new cScpScript("scripts/location.xss"); Scripts::Menus = new cScpScript("scripts/menus.xss"); Scripts::MetaGM = new cScpScript("scripts/metagm.xss"); Scripts::Misc = new cScpScript("scripts/misc.xss"); Scripts::MsgBoard = new cScpScript("scripts/msgboard.xss"); Scripts::Necro = new cScpScript("scripts/necro.xss"); Scripts::Newbie = new cScpScript("scripts/newbie.xss"); Scripts::Npc = new cScpScript("scripts/npc.xss"); Scripts::NpcMagic = new cScpScript("scripts/npcmagic.xss"); // Scripts::NTrigrs = new cScpScript("ntrigrs.scp"); // Scripts::Override = new cScpScript("override.scp"); // Scripts::Polymorph = new cScpScript("scripts/polymorph.xss"); Race::load("scripts/race.xss"); Scripts::Regions = new cScpScript("scripts/regions.xss"); Scripts::Skills = new cScpScript("scripts/skills.xss"); Scripts::Spawn = new cScpScript("scripts/spawn.xss"); Scripts::Speech = new cScpScript("scripts/speech.xss"); Scripts::Spells = new cScpScript("scripts/spells.xss"); // Scripts::Teleport = new cScpScript("teleport.scp"); Scripts::Titles = new cScpScript("scripts/titles.xss"); Scripts::Triggers = new cScpScript("scripts/triggers.xss"); // Scripts::WTrigrs = new cScpScript("wtrigrs.scp"); Scripts::Mountable = new cScpScript("scripts/mounts.xss"); Scripts::WeaponInfo = new cScpScript("scripts/weaponinfo.xss"); Scripts::Containers = new cScpScript("scripts/containers.xss"); Scripts::Areas = new cScpScript("scripts/areas.xss"); Scripts::Magic = new cScpScript("scripts/magic.xss"); }
bool IDevice::free() { safedelete(_colorResolveEffect); safedelete(_depthResolveEffect); safedelete(_vertexDeclarationMgr); safedelete(_shaderMgr); safedelete(_shaderValueFactory); safedelete(_postEffectsMgr); safedelete(_textureMgr); _application = nullptr; return true; }
/*! \brief Change password of account \author Endymion */ void cAccount::changePassword ( std::string password ) { if (ServerScp::g_nUseAccountEncryption) { //xan : for account DES encryption :) char str[1000]; strcpy(str,password.c_str()); char *pwd = pwdcypher(str, -1); str[0] = '!'; str[1] = '\0'; strcat(str,pwd); safedelete(pwd); //xan : avoid a repetitive memory leak :) password.erase(); password = str; //someone with a bit of knowledge about STL strings.. plz chg this! } this->pass = password; }
bool VertexDeclarationD3D11::initialize (const Ibl::VertexDeclarationParameters* resource) { safedelete(_vertexAttributes); const std::vector<Ibl::VertexElement> & elements = resource->elements(); if (elements.size() == 0) return false; _vertexAttributes = new D3D11_INPUT_ELEMENT_DESC[elements.size()]; uint32_t index = 0; for (uint32_t i = 0; i < elements.size() - 1; i++) { const Ibl::VertexElement& element = elements[i]; _vertexAttributes[index] = createVertexElement (element.stream(), element.offset(), element.type(), element.method(), element.usage(), element.usageIndex(), element.streamIndex()); index++; } Ibl::VertexElement element = elements[elements.size()-2]; _vertexStride = (element.offset() + VertexDeclarationD3D11::elementToSize(element.type())); _elementCount = (uint32_t)(elements.size()) - 1; index = 0; for (auto it = elements.begin(); it != elements.end(); it++) { _declaration.push_back (*it); index++; } return create(); }
/*! \author Luxor \brief Deletes every tempfx of the specified number */ void cObject::delTempfx( int32_t num, bool executeExpireCode, uint32_t funcidx ) { if ( num < 0 || num >= tempfx::MAX_TEMPFX_INDEX ) return; if ( !hasTempfx() ) return; TempfxVector::iterator it( tempfx->begin() ); for ( ; it != tempfx->end(); ) { if( ( it->getNum() != num ) || ( it->getAmxCallback() != funcidx ) ) { it++; continue; } if ( executeExpireCode ) it->executeExpireCode(); it = tempfx->erase( it ); } if ( tempfx->empty() ) safedelete( tempfx ); }
void deleteNewScripts() { cScpScript* Dummy = new cScpScript("scripts/symbols.xss"); safedelete(Dummy);// safedelete(Scripts::Advance );//= new cScpScript("scripts/advance.xss"); // Scripts::Calendar = new cScpScript("calendar.scp"); safedelete(Scripts::Carve );//= new cScpScript("carve.scp"); safedelete(Scripts::Colors );//= new cScpScript("colors.scp"); safedelete(Scripts::Create );//= new cScpScript("create.scp"); // Scripts::CronTab = new cScpScript("crontab.scp"); safedelete(Scripts::Envoke );//= new cScpScript("envoke.scp"); safedelete(Scripts::Fishing );//= new cScpScript("fishing.scp"); safedelete(Scripts::HardItems );//= new cScpScript("harditems.scp"); safedelete(Scripts::House );//= new cScpScript("house.scp"); safedelete(Scripts::Creatures ); safedelete(Scripts::HostDeny); safedelete(Scripts::HtmlStrm );//= new cScpScript("htmlstrm.scp"); safedelete(Scripts::Items );//= new cScpScript("items.scp"); safedelete(Scripts::Location );//= new cScpScript("location.scp"); safedelete(Scripts::Magic );//= new cScpScript("scripts/menus.xss"); safedelete(Scripts::Menus );//= new cScpScript("scripts/menus.xss"); safedelete(Scripts::MetaGM );//= new cScpScript("metagm.scp"); safedelete(Scripts::Misc );//= new cScpScript("misc.scp"); safedelete(Scripts::MList );//= new cScpScript("mlist.scp"); safedelete(Scripts::MsgBoard);// = new cScpScript("msgboard.scp"); safedelete(Scripts::Necro );//= new cScpScript("scripts/necro.xss"); safedelete(Scripts::Newbie );//= new cScpScript("newbie.scp"); safedelete(Scripts::Npc );// new cScpScript("scripts/npc.xss"); safedelete(Scripts::NpcMagic);// = new cScpScript("npcmagic.scp"); // safedelete(Scripts::NTrigrs);// = new cScpScript("ntrigrs.scp"); // Scripts::Override = new cScpScript("override.scp"); // safedelete(Scripts::Polymorph);// = new cScpScript("polymorph.scp"); safedelete(Scripts::Regions);// = new cScpScript("regions.scp"); safedelete(Scripts::Skills);// = new cScpScript("skills.scp"); safedelete(Scripts::Spawn);// = new cScpScript("spawn.scp"); safedelete(Scripts::Speech);// = new cScpScript("speech.scp"); safedelete(Scripts::Spells);// = new cScpScript("spells.scp"); // safedelete(Scripts::Teleport);// = new cScpScript("teleport.scp"); safedelete(Scripts::Titles);// = new cScpScript("titles.scp"); safedelete(Scripts::Triggers);// = new cScpScript("triggers.scp"); // safedelete(Scripts::WTrigrs);// = new cScpScript("wtrigrs.scp"); safedelete(Scripts::Mountable); safedelete(Scripts::WeaponInfo); safedelete(Scripts::Containers); safedelete(Scripts::Areas); }
IBLRenderPass::~IBLRenderPass() { safedelete(_sphereEntity); safedelete(_material); }
void newbieitems(P_CHAR pc) { VALIDATEPC(pc); NXWCLIENT ps=pc->getClient(); if(ps==NULL) return; int first, second, third, storeval, itemaddperskill, loopexit = 0; char sect[512]; char whichsect[105]; cScpIterator* iter = NULL; first = bestskill(pc); second = nextbestskill(pc, first); third = nextbestskill(pc, second); if (pc->baseskill[third] < 190) third = 46; for (itemaddperskill = 1; itemaddperskill <= 5; itemaddperskill++) { switch (itemaddperskill) { // first of all the general section with the backpack, else where we put items? case 1: strcpy(whichsect, "SECTION ALLNEWBIES"); break; case 2: if ( (pc->getId() == BODY_MALE) && (pc->getOldId() == BODY_MALE) ) strcpy(whichsect, "SECTION MALENEWBIES"); else strcpy(whichsect, "SECTION FEMALENEWBIES"); break; case 3: sprintf(whichsect, "SECTION BESTSKILL %i", first); break; case 4: sprintf(whichsect, "SECTION BESTSKILL %i", second); break; case 5: sprintf(whichsect, "SECTION BESTSKILL %i", third); break; default: ErrOut("Switch fallout. newbie.cpp, newbieitems()/n"); // Morrolan } sprintf(sect, whichsect); char script1[1000], script2[1000]; safedelete(iter); iter = Scripts::Newbie->getNewIterator(sect); if (iter==NULL) return; do { iter->parseLine(script1,script2); if (script1[0] == '@') pc->loadEventFromScript(script1, script2); // Sparhawk: Huh loading character events // from newbie item scripts???? if (script1[0] != '}') { if (!(strcmp("PACKITEM", script1))) { std::string itemnum, amount; splitLine( script2, itemnum, amount ); int amt = ( amount != "" )? str2num( amount ) : INVALID; //ndEndy defined amount P_ITEM pi_n = item::CreateFromScript( str2num( itemnum ), pc->getBackpack(), amt ); if (ISVALIDPI(pi_n)) { pi_n->priv |= 0x02; // Mark as a newbie item } strcpy(script1, "DUMMY"); } else if (!strcmp("BANKITEM", script1)) { std::string itemnum, amount; splitLine( script2, itemnum, amount ); int amt= (amount!="")? str2num( amount ) : INVALID; P_ITEM pi = item::CreateFromScript( str2num( itemnum ), pc->GetBankBox(), amt ); if (ISVALIDPI(pi)) { pi->priv |= 0x02; // Mark as a newbie item } strcpy(script1, "DUMMY"); } else if (!strcmp("EQUIPITEM", script1)) { P_ITEM pi = item::CreateFromScript( script2 ); if (ISVALIDPI(pi)) { pi->priv |= 0x02; // Mark as a newbie item pi->setCont(pc); storeval = pi->getScriptID(); } strcpy(script1, "DUMMY"); } } } while ((script1[0] != '}') &&(++loopexit < MAXLOOPS)); safedelete(iter); } // Give the character some gold if ( goldamount > 0 ) { item::CreateFromScript( "$item_gold_coin", pc->getBackpack(), goldamount ); } }
void loadcustomtitle() // for custom titles { int titlecount=0; char sect[512]; cScpIterator* iter = NULL; char script1[1024]; char script2[1024]; for (int a=0; a<ALLSKILLS; a++) { title[a].fame[0] = 0; title[a].other[0] = 0; title[a].prowess[0] = 0; title[a].skill[0] = 0; } strcpy(sect,"SECTION SKILL"); iter = Scripts::Titles->getNewIterator(sect); if (iter==NULL) return; int loopexit=0; do { iter->parseLine(script1, script2); if ((script1[0]!='}')&&(script1[0]!='{')) { if ( !strcmp(script1, "TITLE") ) { strcpy(title[titlecount].skill,script2); titlecount++; } else if ( !strcmp(script1, "SKIP") ) { strcpy(title[titlecount].skill," "); titlecount++; } } } while ((script1[0]!='}') && (++loopexit < MAXLOOPS) ); safedelete(iter); script1[0]=0; titlecount=0; strcpy(sect,"SECTION PROWESS"); iter = Scripts::Titles->getNewIterator(sect); if (iter==NULL) return; loopexit=0; do { strcpy(script1, iter->getEntry()->getFullLine().c_str()); if ((script1[0]!='}')&&(script1[0]!='{')) { if ( !strcmp(script1, "NONE") ) ; else strcpy(title[titlecount].prowess,script1); titlecount++; } } while ((script1[0]!='}') && (++loopexit < MAXLOOPS) ); safedelete(iter); script1[0]=0; titlecount=0; strcpy(sect,"SECTION FAME"); iter = Scripts::Titles->getNewIterator(sect); if (iter==NULL) return; loopexit=0; do { strcpy(script1, iter->getEntry()->getFullLine().c_str()); if ((script1[0]!='}')&&(script1[0]!='{')) { if ( !strcmp(script1, "NONE") ) ; else strcpy(title[titlecount].fame, script1); if (titlecount==23) { title[titlecount].fame[0] = '\0'; strcpy(title[++titlecount].fame, script1); } titlecount++; } } while ((script1[0]!='}') && (++loopexit < MAXLOOPS) ); safedelete(iter); script1[0]=0; titlecount=0; strcpy(sect,"SECTION OTHER"); iter = Scripts::Titles->getNewIterator(sect); if (iter==NULL) return; loopexit=0; do { strcpy(script1, iter->getEntry()->getFullLine().c_str()); if ((script1[0]!='}')&&(script1[0]!='{')) { if ( !strcmp(script1, "NONE") ) ; else strcpy(title[titlecount].other,script1); titlecount++; } } while ((script1[0]!='}') && (++loopexit < MAXLOOPS) ); safedelete(iter); }
void loadregions()//New -- Zippy spawn regions { int i, noregion, l=0, a=0,loopexit=0; char sect[512]; int actgood=INVALID; // Magius(CHE) cScpIterator* iter = NULL; char script1[1024]; char script2[1024]; for (i=0;i<256;i++) { region_st ®ionRef = region[i]; regionRef.inUse = false; regionRef.midilist=0; regionRef.priv=0; regionRef.drychance=0; regionRef.keepchance=0; regionRef.wtype = 0; regionRef.snowchance=0; regionRef.rainchance=0; regionRef.forcedseason = INVALID; regionRef.ignoreseason = false; regionRef.name[0]=0; noregion=0; for (a=0;a<10;a++) { regionRef.guardnum[a]=RandomNum(1000,1001); } for (a=0;a<100;a++) // added by Magius(CHE) { regionRef.goodsell[a]=0; regionRef.goodbuy[a]=0; regionRef.goodrnd1[a]=0; regionRef.goodrnd2[a]=0; } a=0; // end added by Magius(CHE) sprintf(sect, "SECTION REGION %i", i); safedelete(iter); //as the name implies, this is safe :P, Xan iter = Scripts::Regions->getNewIterator(sect); if (iter==NULL) { noregion=1; continue; //-> goes next loop! } regionRef.inUse = true; loopexit=0; do { iter->parseLine(script1, script2); if ((script1[0]!='}')&&(script1[0]!='{')) { if (!(strcmp("GUARDNUM",script1))) { if (a<10) { regionRef.guardnum[a]=str2num(script2); a++; } else { LogWarning("region %i has more than 10 'GUARDNUM', The ones after 10 will not be used\n",i); } } else if (!(strcmp("NAME",script1))) { strcpy(regionRef.name,script2); actgood=INVALID; // Magius(CHE) } // Dupois - Added April 5, 1999 // To identify whether this region is escortable or not. else if (!(strcmp("ESCORTS",script1))) { // Load the region number in the global array of valid escortable regions if ( str2num(script2) == 1 ) { // Store the region index into the valid escort region array validEscortRegion[escortRegions] = i; escortRegions++; } } // End - Dupois else if (!(strcmp("GUARDOWNER",script1))) strcpy(regionRef.guardowner,script2); else if (!(strcmp("MIDILIST",script1))) regionRef.midilist=str2num(script2); else if (!(strcmp("GUARDED",script1))) { if (str2num(script2)) regionRef.priv|=0x01; } else if (!(strcmp("MAGICDAMAGE",script1))) { if ((str2num(script2))) regionRef.priv|=0x40; // bugfix LB 12-march- // changes from 0=magicdamge,1=no magic damage // to 1= 0= } else if (!(strcmp("NOMAGIC",script1))) { if ((str2num(script2))) regionRef.priv|=0x80; } else if (!(strcmp("MARK",script1))) { if (str2num(script2)) regionRef.priv|=0x02; } else if (!(strcmp("GATE",script1))) { if (str2num(script2)) regionRef.priv|=0x04; } else if (!(strcmp("RECALL",script1))) { if (str2num(script2)) regionRef.priv|=0x08; } else if (!(strcmp("SNOWCHANCE", script1))) { regionRef.snowchance=str2num(script2); } else if (!(strcmp("RAINCHANCE", script1))) { regionRef.rainchance=str2num(script2); } //xan : quick&dirty weather system :) else if (!(strcmp("DRYCHANCE", script1))) { regionRef.drychance=str2num(script2); } else if (!(strcmp("KEEPCHANCE", script1))) { regionRef.keepchance=str2num(script2); } else if (!(strcmp("FORCESEASON", script1))) { regionRef.forcedseason =str2num(script2); } else if (!(strcmp("IGNOREMONTHMULTIPLIERS", script1))) { regionRef.ignoreseason =true; } else if (!(strcmp("GOOD", script1))) // Magius(CHE) { actgood=str2num(script2); } else if (!(strcmp("BUYABLE", script1))) // Magius(CHE) { if (actgood>INVALID) regionRef.goodbuy[actgood]=str2num(script2); else LogError("error in regions.xss. You must write BUYABLE after GOOD <num>!\n"); } else if (!(strcmp("SELLABLE", script1))) // Magius(CHE) { if (actgood>INVALID) regionRef.goodsell[actgood]=str2num(script2); else LogError("error in regions.xss. You must write SELLABLE after GOOD <num>!\n"); } else if (!(strcmp("RANDOMVALUE", script1))) // Magius(CHE) (2) { if (actgood>INVALID) { gettokennum(script2, 0); regionRef.goodrnd1[actgood]=str2num(gettokenstr); gettokennum(script2, 1); regionRef.goodrnd2[actgood]=str2num(gettokenstr); if (regionRef.goodrnd2[actgood]<regionRef.goodrnd1[actgood]) { LogError("error in regions.xss. You must write RANDOMVALUE NUM2[%i] grater than NUM1[%i].\n",regionRef.goodrnd2[actgood],regionRef.goodrnd1[actgood]); regionRef.goodrnd2[actgood]=regionRef.goodrnd1[actgood]=0; } } else LogError("error in regions.xss. You must write RANDOMVALUE after GOOD <num>!\n"); } else if (!(strcmp("X1", script1))) { location[l].x1=str2num(script2); } else if (!(strcmp("X2", script1))) { location[l].x2=str2num(script2); } else if (!(strcmp("Y1", script1))) { location[l].y1=str2num(script2); } else if (!(strcmp("Y2", script1))) { location[l].y2=str2num(script2); location[l].region=i; l++; } } } while (script1[0]!='}' && !noregion && (++loopexit < MAXLOOPS) ); } locationcount=l; logoutcount=0; //Instalog strcpy(sect, "SECTION INSTALOG"); safedelete(iter); //as the name implies, this is safe :P, Xan iter = Scripts::Regions->getNewIterator(sect); if (iter==NULL) return; loopexit=0; do { iter->parseLine(script1, script2); if(!(strcmp(script1,"X1"))) logout[logoutcount].x1=str2num(script2); if(!(strcmp(script1,"Y1"))) logout[logoutcount].y1=str2num(script2); if(!(strcmp(script1,"X2"))) logout[logoutcount].x2=str2num(script2); if(!(strcmp(script1,"Y2"))) { logout[logoutcount].y2=str2num(script2); logoutcount++; } } while ( (script1[0]!='}') && (++loopexit < MAXLOOPS) ); safedelete(iter); }
void loadcontainers() { cScpIterator* iter = NULL; std::string script1, script2; SI32 gump = INVALID; BasicPosition uprleft = {INVALID,INVALID}; BasicPosition dwnrght = {INVALID,INVALID}; UI32VECTOR *vet = new UI32VECTOR; int cont=0; int loopexit=0; do { safedelete(iter); iter = Scripts::Containers->getNewIterator("SECTION CONTAINER %i", cont++); if( iter==NULL ) continue; gump = INVALID; uprleft.x = INVALID; uprleft.y = INVALID; dwnrght.x = INVALID; dwnrght.y = INVALID; vet->clear(); do { iter->parseLine(script1, script2); if ( script1[0]!='}' && script1[0]!='{' ) { if ( "ID" == script1 ) vet->push_back( str2num( script2 ) ); else if ( "GUMP" == script1 ) gump = str2num( script2 ); else if ( "X1" == script1 ) uprleft.x= str2num( script2 ); else if ( "Y1" == script1 ) uprleft.y= str2num( script2 ); else if ( "X2" == script1 ) dwnrght.x= str2num( script2 ); else if ( "Y2" == script1 ) dwnrght.y= str2num( script2 ); else WarnOut("[ERROR] wrong line ( %s ) parsed on containers.xss", script1.c_str() ); } } while ( script1[0] !='}' && ++loopexit < MAXLOOPS ); if( (gump!=INVALID) && (uprleft.x!=INVALID) && (dwnrght.x!=INVALID) && (uprleft.y!=INVALID) && (dwnrght.y!=INVALID) ) { cont_gump_st dummy; dummy.downright = dwnrght; dummy.upperleft = uprleft; dummy.gump = gump; contInfoGump[gump] = dummy; CONTINFOGUMPMAP::iterator iter( contInfoGump.find(gump) ); if( iter != contInfoGump.end() ) { UI32VECTOR::iterator ids( vet->begin() ), end( vet->end() ); for(; ids != end; ++ids ) contInfo[(*ids)] = iter; } else ConOut("[ERROR] on parse of containers.xss" ); } else ConOut("[ERROR] on parse of containers.xss" ); } while ( script1 != "EOF" && ++loopexit < MAXLOOPS ); safedelete(iter); // ConOut("\n"); // for(CONTINFOMAP::iterator debug=contInfo.begin(); debug!=contInfo.end(); debug++ ) // ConOut( "id %i ha gump %i \n ", debug->first, (debug->second)->second.gump); }
DepthSurfaceD3D11::~DepthSurfaceD3D11() { safedelete (_initializationData); free(); }
/*! \author Zippy \brief Build an house Triggered by double clicking a deed-> the deed's morex is read for the house section in house.cpp. Extra items can be added using HOUSE ITEM, (this includes all doors!) and locked "LOCK" Space around the house with SPACEX/Y and CHAR offset CHARX/Y/Z \todo Remove temp variable */ void buildhouse( pClient client, pTarget t ) { int i = t->buffer[2]; char temp[TEMP_STR_SIZE]; //xan -> this overrides the global temp var int loopexit=0;//where they click, and the house/key items uint32_t k, sx = 0, sy = 0, icount=0; uint16_t x, y, id_tile; int16_t z; int hitem[100];//extra "house items" (up to 100) char sect[512]; //file reading char itemsdecay = 0; // set to 1 to make stuff decay in houses static int looptimes=0; //for targeting int cx=0,cy=0,cz=8; //where the char is moved to when they place the house (Inside, on the steps.. etc...)(Offset) int boat=0;//Boats int hdeed=0;//deed id # int norealmulti=0,nokey=0,othername=0; char name[512]; pChar pc = client->currChar(); if ( ! pc ) return; sLocation charpos= pc->getPosition(); int16_t id = INVALID; //house ID hitem[0]=0;//avoid problems if there are no HOUSE_ITEMs by initializing the first one as 0 if (i) { cScpIterator* iter = NULL; char script1[1024]; char script2[1024]; sprintf(sect, "SECTION HOUSE %d", i);//and BTW, .find() adds SECTION on there for you.... iter = Scripts::House->getNewIterator(sect); if (iter==NULL) return; do { iter->parseLine(script1, script2); if ((script1[0]!='}')&&(script1[0]!='{')) { if (!(strcmp(script1,"ID"))) { id = hex2num(script2); } else if (!(strcmp(script1,"SPACEX"))) { sx=str2num(script2)+1; } else if (!(strcmp(script1,"SPACEY"))) { sy=str2num(script2)+1; } else if (!(strcmp(script1,"CHARX"))) { cx=str2num(script2); } else if (!(strcmp(script1,"CHARY"))) { cy=str2num(script2); } else if (!(strcmp(script1,"CHARZ"))) { cz=str2num(script2); } else if( !(strcmp(script1, "ITEMSDECAY" ))) { itemsdecay = str2num( script2 ); } else if (!(strcmp(script1,"HOUSE_ITEM"))) { hitem[icount]=str2num(script2); icount++; } else if (!(strcmp(script1, "HOUSE_DEED"))) { hdeed=str2num(script2); } else if (!(strcmp(script1, "BOAT"))) boat=1;//Boats else if (!(strcmp(script1, "NOREALMULTI"))) norealmulti=1; // LB bugfix for pentas crashing client else if (!(strcmp(script1, "NOKEY"))) nokey=1; else if (!(strcmp(script1, "NAME"))) { strcpy(name,script2); othername=1; } } } while ( (strcmp(script1,"}")) && (++loopexit < MAXLOOPS) ); safedelete(iter); if (!id) { ErrOut("Bad house script # %i!\n",i); return; } } if(!looptimes) { if (i) { if (norealmulti) { pTarget targ = clientInfo[s]->newTarget( new cLocationTarget() ); targ->code_callback=buildhouse; ShortToCharPtr(0x4064, t->buffer); targ->send( ps ); ps->sysmsg( "Select a place for your structure: "); } else client->sysmessage("Select location for building."); nPackets::Sent::TargetMulti pk(0x00010000/*serial*/, id -0x4000/*model*/); client->sendPacket(&pk); } else { client->sysmessage("Select location for building."); nPackets::Sent::TargetMulti pk(0x00010000/*serial*/, ShortFromCharPtr(t->buffer) -0x4000/*model*/); client->sendPacket(&pk); } looptimes++;//for when we come back after they target something return; } if(looptimes) { looptimes=0; if(!pc->IsGM() && SrvParms->houseintown==0) { if ((region[pc->region].priv & rgnFlagGuarded) && itemById::IsHouse(id) ) // popy { client->sysmessage(" You cannot build houses in town!"); return; } } x = ShortFromCharPtr(buffer[s] +11); //where they targeted y = ShortFromCharPtr(buffer[s] +13); z = ShortFromCharPtr(buffer[s] +15); id_tile = ShortFromCharPtr(buffer[s] +17); z += tileHeight(id_tile); //XAN : House placing fix :) if ( (( x<XBORDER || y <YBORDER ) || ( x>(uint32_t)((map_width*8)-XBORDER) || y >(uint32_t)((map_height*8)-YBORDER) )) ) { client->sysmessage("You cannot build your structure there!"); return; } /* if (ishouse(id1, id2)) // strict checking only for houses ! LB { if(!(CheckBuildSite(x,y,z,sx,sy))) { client->sysmessage("Can not build a house at that location (CBS)!"); return; } }*/ for (k=0;k<sx;k++)//check the SPACEX and SPACEY to make sure they are valid locations.... { for (uint32_t l=0;l<sy;l++) { sLocation loc; loc.x=x+k; loc.y=y+l; loc.z=z; sLocation newpos = sLocation( x+k, y+l, z ); if ( (isWalkable( newpos ) == illegal_z ) && ((charpos.x != x+k)&&(charpos.y != y+l)) ) /*This will take the char making the house out of the space check, be careful you don't build a house on top of your self..... this had to be done So you could extra space around houses, (12+) and they would still be buildable.*/ { client->sysmessage("You cannot build your stucture there."); return; //ConOut("Invalid %i,%i [%i,%i]\n",k,l,x+k,y+l); } //else ConOut("DEBUG: Valid at %i,%i [%i,%i]\n",k,l,x+k,y+l); if ( !norealmulti && cMulti::getAt(loc) ) { client->sysmessage("You cant build structures inside structures"); return; } } } if((id % 256)>=18) sprintf(temp,"%s's house",pc->getCurrentName().c_str());//This will make the little deed item you see when you have showhs on say the person's name, thought it might be helpful for GMs. else strcpy(temp, "a mast"); if(norealmulti) strcpy(temp, name); //--^ if (othername) strcpy(temp,name); if (id == INVALID) return; pItem pHouse = item::CreateFromScript( "$item_hardcoded" ); if ( !pHouse ) return; pHouse->setId( id ); pHouse->setCurrentName( temp ); pc->making=0; pHouse->setPosition(x, y, z); pHouse->setDecay( false ); pHouse->setNewbie( false ); pHouse->setDispellable( false ); pHouse->more4 = itemsdecay; // set to 1 to make items in houses decay pHouse->morex=hdeed; // crackerjack 8/9/99 - for converting back *into* deeds pHouse->setOwner(pc); if (pHouse->isInWorld()) { mapRegions->add(pHouse); } if (!hitem[0] && !boat) { pc->teleport(); return;//If there's no extra items, we don't really need a key, or anything else do we? ;-) } if(boat) { if(!Build(s,pHouse, id%256/*id2*/)) { pHouse->Delete(); return; } } if (i) { pItem pFx1 = MAKE_ITEM_REF( pc->fx1 ); if ( pFx1 != 0 ) pFx1->Delete(); // this will del the deed no matter where it is } pc->fx1=-1; //reset fx1 so it does not interfere // bugfix LB ... was too early reseted pItem pKey=NULL; pItem pKey2=NULL; pItem pBackPack = pc->getBackpack(); //Key... //Altered key naming to include pc's name. Integrated backpack and bankbox handling (Sparhawk) if ((id%256 >=0x70) && (id%256 <=0x73)) { sprintf(temp,"%s's tent key",pc->getCurrentName().c_str()); pKey = item::CreateFromScript( "$item_iron_key", pBackPack ); //iron key for tents pKey2= item::CreateFromScript( "$item_iron_key", pBackPack ); } else if(id%256 <=0x18) { sprintf(temp,"%s's ship key",pc->getCurrentName().c_str()); pKey= item::CreateFromScript( "$item_bronze_key", pBackPack ); //Boats -Rusty Iron Key pKey2= item::CreateFromScript( "$item_bronze_key", pBackPack ); } else { sprintf(temp,"%s's house key",pc->getCurrentName().c_str()); pKey= item::CreateFromScript( "$item_gold_key", pBackPack ); //gold key for everything else; pKey2= item::CreateFromScript( "$item_gold_key", pBackPack ); } if ( ! pKey || ! pKey2 ) return; pKey->Refresh(); pKey2->Refresh(); pHouse->st = pKey->getSerial(); // Create link from house to housekeys to allow easy renaming of pHouse->st2= pKey2->getSerial(); // house, housesign and housekeys without having to loop trough // all world items (Sparhawk) pKey->more = pHouse->getSerial(); //use the house's serial for the more on the key to keep it unique pKey->type=ITYPE_KEY; pKey->setNewbie(); pKey2->more = pHouse->getSerial(); //use the house's serial for the more on the key to keep it unique pKey2->type=ITYPE_KEY; pKey2->setNewbie(); pItem bankbox = pc->GetBankBox(); if(bankbox!=NULL) // we sould add a key in bankbox only if the player has a bankbox =) { pItem p_key3=item::CreateFromScript( "$item_gold_key" ); if ( ! p_key3 ) return; p_key3->setCurrentName( "a house key" ); p_key3->more = pHouse->getSerial(); p_key3->type=ITYPE_KEY; p_key3->setNewbie(); bankbox->AddItem(p_key3); } if(nokey) { pKey->Delete(); // No key for .. nokey items pKey2->Delete(); // No key for .. nokey items } for (k=0;k<icount;k++)//Loop through the HOUSE_ITEMs { cScpIterator* iter = NULL; char script1[1024]; char script2[1024]; sprintf(sect,"SECTION HOUSE ITEM %i",hitem[k]); iter = Scripts::House->getNewIterator(sect); if (iter!=NULL) { pItem pi_l=NULL; loopexit=0; do { iter->parseLine(script1, script2); if (script1[0]!='}') { if (!(strcmp(script1,"ITEM"))) { pi_l=item::CreateScriptItem(s,str2num(script2),0);//This opens the item script... so we gotta keep track of where we are with the other script. if(pi_l) { pi_l->magic=2;//Non-Movebale by default pi_l->setDecay( false ); //since even things in houses decay, no-decay by default pi_l->setNewbie( false ); pi_l->setDispellable( false ); pi_l->setPosition(x, y, z); pi_l->setOwner(pc); // SPARHAWK 2001-01-28 Added House sign naming if (pi_l->IsSign()) if ((id%256 >=0x70) && (id%256<=0x73)) pi_l->setCurrentName("%s's tent",pc->getCurrentName().c_str()); else if (id%256<=0x18) pi_l->setCurrentName("%s's ship",pc->getCurrentName().c_str()); else pi_l->setCurrentName("%s's house",pc->getCurrentName().c_str()); } } if (!(strcmp(script1,"DECAY"))) { if (pi_l) pi_l->setDecay(); } if (!(strcmp(script1,"NODECAY"))) { if (pi_l) pi_l->setDecay( false ); } if (!(strcmp(script1,"PACK")))//put the item in the Builder's Backpack { if (pi_l) pi_l->setContainer(pc->getBackpack()); if (pi_l) pi_l->setPosition("x", rand()%90+31); if (pi_l) pi_l->setPosition("y", rand()%90+31); if (pi_l) pi_l->setPosition("z", 9); } if (!(strcmp(script1,"MOVEABLE"))) { if (pi_l) pi_l->magic=1; } if (!(strcmp(script1,"LOCK")))//lock it with the house key { if (pi_l) pi_l->more = pHouse->getSerial(); } if (!(strcmp(script1,"X")))//offset + or - from the center of the house: { if (pi_l) pi_l->setPosition("x", x+str2num(script2)); } if (!(strcmp(script1,"Y"))) { if (pi_l) pi_l->setPosition("y", y+str2num(script2)); } if (!(strcmp(script1,"Z"))) { if (pi_l) pi_l->setPosition("z", z+str2num(script2)); } } } while ( (strcmp(script1,"}")) && (++loopexit < MAXLOOPS) ); if (pi_l) if (pi_l->isInWorld()) { mapRegions->add(pi_l); } safedelete(iter); } } NxwSocketWrapper sw; sw.fillOnline( pc, false ); for( sw.rewind(); !sw.isEmpty(); sw++ ) { pClient ps_i = sw.getClient(); if(ps_i==NULL) continue; pChar pc_i=ps_i->currChar(); if(pc_i) pc_i->teleport(); } //</Luxor> if (!(norealmulti)) { charpos.x= x+cx; //move char inside house charpos.y= y+cy; charpos.dispz= charpos.z= z+cz; pc->setPosition( charpos ); //ConOut("Z: %i Offset: %i Char: %i Total: %i\n",z,cz,chars[currchar[s]].z,z+cz); pc->teleport(); } } }
/*! \author Luxor \brief Calls the pathfinding algorithm and creates a new path */ void cChar::pathFind( sLocation pos, bool bOverrideCurrentPath ) { if ( hasPath() ) { if ( bOverrideCurrentPath ) safedelete( path ); else return; } bool bOk = true; sLocation loc = pos; if ( isWalkable( pos, WALKFLAG_ALL, this ) == illegal_z ) { // If it isn't walkable, we can only reach the nearest tile bOk = false; for ( uint32_t i = 1; i < 4; i++ ) { // East loc = sLocation( pos.x + i, pos.y, pos.z ); if ( isWalkable( loc, WALKFLAG_ALL, this ) != illegal_z ) { bOk = true; break; } // West loc = sLocation( pos.x - i, pos.y, pos.z ); if ( isWalkable( loc, WALKFLAG_ALL, this ) != illegal_z ) { bOk = true; break; } // South loc = sLocation( pos.x, pos.y + i, pos.z ); if ( isWalkable( loc, WALKFLAG_ALL, this ) != illegal_z ) { bOk = true; break; } // North loc = sLocation( pos.x, pos.y - i, pos.z ); if ( isWalkable( loc, WALKFLAG_ALL, this ) != illegal_z ) { bOk = true; break; } // North-East loc = sLocation( pos.x + i, pos.y - i, pos.z ); if ( isWalkable( loc, WALKFLAG_ALL, this ) != illegal_z ) { bOk = true; break; } // North-West loc = sLocation( pos.x - i, pos.y - i, pos.z ); if ( isWalkable( loc, WALKFLAG_ALL, this ) != illegal_z ) { bOk = true; break; } // South-East loc = sLocation( pos.x + i, pos.y + i, pos.z ); if ( isWalkable( loc, WALKFLAG_ALL, this ) != illegal_z ) { bOk = true; break; } // South-West loc = sLocation( pos.x - i, pos.y + i, pos.z ); if ( isWalkable( loc, WALKFLAG_ALL, this ) != illegal_z ) { bOk = true; break; } } } if ( bOk ) path = new cPath( getPosition(), loc, this ); }
void updatehtml()//HTML { double eps=0.00000000001; char sect[512],time_str[80],hfile[512] /*,sh[3],sm[3],ss[3]*/; int a, n=0; //unsigned long int ip; int gm=0,cns=0,ccount=0,npccount=0,loopexit=0; unsigned long int total; unsigned int hr,min,sec; FILE *html; cScpIterator* iter = NULL; //char script1[1024]; //char script2[1024]; std::string script1; std::string script2; strcpy(sect,"SECTION ONLINE"); iter = Scripts::HtmlStrm->getNewIterator(sect); if (iter==NULL) return; script1 = iter->getEntry()->getFullLine(); //discard { script1 = iter->getEntry()->getFullLine(); strcpy( hfile, script1.c_str() ); //html=fopen(hfile,"w+"); //a=remove(hfile); //ConOut("html-a: %i %s\n",a,hfile); html=fopen(hfile,"w"); // remove old one first if (html == NULL) // LB { WarnOut("Could not create html file, please check html.xss\n"); safedelete(iter); return; } do { iter->parseLine(script1, script2); if( script1 == "LINE" ) { fprintf(html,"%s\n",script2.c_str() ); } else if( script1 == "TIME" ) { fprintf(html,"%s <BR>",RealTime(time_str)); } else if( script1 == "NOW" ) { P_CHAR pc= MAKE_CHAR_REF(currchar[n]); //if(online(currchar[n])) //bugfix LB if( ISVALIDPC(pc) && pc->IsOnline() ) { fprintf(html,pc->getCurrentNameC()); n++; } } else if( script1 == "WHOLIST" ) { a=0; for (n=0;n<now;n++) { P_CHAR pc= MAKE_CHAR_REF(currchar[n]); //if (online(currchar[n])) // bugfix, LB if( ISVALIDPC(pc) && pc->IsOnline() ) { a++; fprintf(html,"%i) %s <BR>\n",a,pc->getCurrentNameC()); // bugfix lb } } } else if( script1 == "NOWNUM") fprintf(html,"%i",now); else if( script1 == "ACCOUNTNUM" ) fprintf(html,"%i",Accounts->Count()); else if( script1 == "CHARCOUNT" ) { if(ccount==0) { npccount=0; /*for(a=0;a<charcount;a++) { P_CHAR pc_a=MAKE_CHAR_REF(a); if(ISVALIDPC(pc_a)) { if(!pc_a->free) ccount++; if(pc_a->npc && !pc_a->free) npccount++; } }*/ } fprintf(html,"%i",ccount); } else if( script1 == "NPCS" ) { if(npccount==0) { ccount=0; /*for(a=0;a<charcount;a++) { P_CHAR pc_a=MAKE_CHAR_REF(a); if(ISVALIDPC(pc_a)) { if(!pc_a->free) ccount++; if(pc_a->npc && !pc_a->free) npccount++; //bugfix LB } }*/ } fprintf(html,"%i",npccount); } else if( script1 == "ITEMCOUNT" ) { //fprintf(html,"%i",itemcount); } else if( script1 == "UPTIME" ) { total=(uiCurrentTime-starttime)/MY_CLOCKS_PER_SEC; hr=total/3600; // if(hr<10 && hr<=60) sprintf(sh,"0%lu",hr); // else sprintf(sh,"%lu",hr); total-=hr*3600; min=total/60; // if(min<10 && min<=60) sprintf(sm,"0%lu",min); // else sprintf(sm,"%lu",min); total-=min*60; sec=total; // if(sec<10 && sec <=60) sprintf(ss,"0%lu",sec); // else sprintf(ss,"%lu",sec); // fprintf(html,"%s:%s:%s",sh,sm,ss); fprintf(html,"%02d:%02d:%02d",hr,min,sec); } else if( script1 == "IP" ) { //ip=inet_addr(serv[str2num(script2)-1][1]); fprintf(html,serv[str2num(script2)-1][1]); } else if( script1 == "GMNUM" ) { if(gm==0) { for(a=0;a<now;a++) { P_CHAR pc_a=MAKE_CHAR_REF(currchar[a]); if(ISVALIDPC(pc_a) && clientInfo[a]->ingame ) { if( pc_a->IsGM() ) gm++; else if( pc_a->IsCounselor() ) cns++; } } } fprintf(html,"%i",gm); } else if( script1 == "CNSNUM" ) { if(cns==0) { for(a=0;a<now;a++) { P_CHAR pc_a=MAKE_CHAR_REF(currchar[a]); if(ISVALIDPC(pc_a) && clientInfo[a]->ingame ) { if( pc_a->IsGM() ) gm++; else if( pc_a->IsCounselor() ) cns++; //bugfix LB } } } fprintf(html,"%i",cns); } else if( script1 == "PDUMP" ) { fprintf(html,"Network code: %fmsec [%i samples] <BR>",(float)((float)networkTime/(float)networkTimeCount), networkTimeCount); fprintf(html,"Timer code: %fmsec [%i samples] <BR>" , (float)((float)timerTime/(float)timerTimeCount) , timerTimeCount); fprintf(html,"Auto code: %fmsec [%i samples] <BR>" , (float)((float)autoTime/(float)autoTimeCount) , autoTimeCount); fprintf(html,"Loop Time: %fmsec [%i samples] <BR>" , (float)((float)loopTime/(float)loopTimeCount) , loopTimeCount); // fprintf(html,"Characters: %i/Dynamic Items: %i/Dynamic <BR>" , charcount, itemcount); if (!(loopTime <eps || loopTimeCount<eps)) //Bugfix LB fprintf(html,"Simulation Cycles: %f per sec <BR>" , (1000.0*(1.0/(float)((float)loopTime/(float)loopTimeCount)))); else fprintf(html,"Simulation Cylces: too fast to be measured <BR>"); } else if( script1 == "SIMCYC" ) { if (!(loopTime <eps || loopTimeCount<eps)) fprintf(html,"%f" , (1000.0*(1.0/(float)((float)loopTime/(float)loopTimeCount)))); else fprintf(html,"too fast to be measured"); } else if( script1 == "UDTIME" ) fprintf(html,"%f",(float)(SrvParms->html/60)); else if( script1 == "VER" ) fprintf(html,"%s %s [%s]",VER, VERNUMB, OS); } while( (script1[0]!='}') && (++loopexit < MAXLOOPS) ); fclose(html); safedelete(iter); }