From: Anders R. <ma...@us...> - 2003-08-14 23:02:14
|
Update of /cvsroot/planeshift/planeshift/src/server In directory sc8-pr-cvs1:/tmp/cvs-serv28655/src/server Modified Files: adminmanager.cpp cachemanager.cpp psserver.cpp spellmanager.cpp spellmanager.h Log Message: - Added check to verify that needed glyphs are pressent when casting a spell. - Moved psSpell::Effect from spellmanager.cpp to the psspell.cpp file. - Removed some debug printings. Index: adminmanager.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/adminmanager.cpp,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** adminmanager.cpp 1 Aug 2003 17:07:53 -0000 1.36 --- adminmanager.cpp 14 Aug 2003 19:52:12 -0000 1.37 *************** *** 62,66 **** // this makes sure that the player dictionary exists on start up. - entity = celserver->CreateEntity( "pcnpcdialog" ); npcdlg = new psNPCDialog(NULL); npcdlg->Initialize( db ); --- 62,65 ---- *************** *** 564,579 **** { #if 1 - // Create a temp entity with the dialog property class - //csRef<iCelEntity> entity = celserver->CreateEntity( "pcnpcdialog" ); - //csRef<iPcNPCDialog> npcdlg = - // CEL_QUERY_PROPCLASS( entity->GetPropertyClassList(), iPcNPCDialog ); - //bool dictExists = npcdlg->Initialize( database ); - - //printf("Dictionary Status: %d\n", dictExists ); - // If the dictionary already exists then we must add these - // to the cache. This will be done automatically in CreateNPC - // if the dictonary does not exist at this point - - //if ( dictExists ) { Debug1(LOG_ADMIN,"Dictionary Exists"); --- 563,566 ---- Index: cachemanager.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/cachemanager.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** cachemanager.cpp 14 Aug 2003 08:07:23 -0000 1.10 --- cachemanager.cpp 14 Aug 2003 19:52:12 -0000 1.11 *************** *** 569,574 **** way->name = ways[i]["name"]; wayList.Push(way); - printf("Added way: %d %s\n", - way->id,(const char*)way->name); } } --- 569,572 ---- *************** *** 588,593 **** spell->Load(spells[i]); spellList.Push(spell); - printf("Added spell: %d %s\n", - spell->GetID(),(const char*)spell->GetName()); } } --- 586,589 ---- Index: psserver.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/psserver.cpp,v retrieving revision 1.111 retrieving revision 1.112 diff -C2 -d -r1.111 -r1.112 *** psserver.cpp 13 Aug 2003 20:30:50 -0000 1.111 --- psserver.cpp 14 Aug 2003 19:52:12 -0000 1.112 *************** *** 163,167 **** return false; } ! CPrintf("Preloaded mesh names, texture names, part names, image names, race info, sector info, and traits..\n"); if (!CharacterLoader.Initialize()) --- 163,167 ---- return false; } ! CPrintf("Preloaded mesh names, texture names, part names, image names, race info, sector info, traits. item categories, item stats, ways and spells.\n"); if (!CharacterLoader.Initialize()) *************** *** 426,430 **** void psServer::InitMsgStrings() { ! puts("InitMsgStrings()"); iResultSet *rs = database->GetAllMsgStrings(); --- 426,430 ---- void psServer::InitMsgStrings() { ! puts("InitMsgStrings() TODO: Syncronize with CacheManager CommonString store!!"); iResultSet *rs = database->GetAllMsgStrings(); Index: spellmanager.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/spellmanager.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** spellmanager.cpp 12 Aug 2003 23:10:32 -0000 1.26 --- spellmanager.cpp 14 Aug 2003 19:52:12 -0000 1.27 *************** *** 28,32 **** #include "util/eventmanager.h" #include "psprop/pc/pspcchar.h" - #include "util/strutil.h" #include "bulkobjects/pscharacterloader.h" #include "bulkobjects/psspell.h" --- 28,31 ---- *************** *** 99,103 **** void psSpellManager::HandleSpellBook(Client * client, psGUISpellBookMessage& msg) { ! printf("psSpellManager::HandleSpellBook(%d,%s)\n",msg.command, (const char*)msg.commandData); switch ( msg.command ) --- 98,102 ---- void psSpellManager::HandleSpellBook(Client * client, psGUISpellBookMessage& msg) { ! Warning3(LOG_SPELLS,"(%d,%s)\n",msg.command, (const char*)msg.commandData); switch ( msg.command ) *************** *** 105,112 **** case psGUISpellBookMessage::REQUEST: { ! csString buff = client->GetCharacterData()->GetXMLSpellList(); ! ! psGUISpellBookMessage newmsg(client->GetClientNum(),psGUISpellBookMessage::SPELL_LIST,buff); ! SendMessage(newmsg.msg); break; } --- 104,108 ---- case psGUISpellBookMessage::REQUEST: { ! SendSpellBook(client); break; } *************** *** 150,154 **** void psSpellManager::HandleGlyph(Client * client, psGUIGlyphMessage & msg) { ! printf("psSpellManager::HandleGlyph(%d,%s):%d\n",msg.command, (const char*)msg.commandData,client->GetPlayerID()); switch ( msg.command ) --- 146,150 ---- void psSpellManager::HandleGlyph(Client * client, psGUIGlyphMessage & msg) { ! Warning4(LOG_SPELLS,"(%d,%s):%d\n",msg.command, (const char*)msg.commandData,client->GetPlayerID()); switch ( msg.command ) *************** *** 295,300 **** psServer::CharacterLoader.SaveCharacterData(client->GetCharacterData(),client->GetActor()); - } void psSpellManager::Cast(Client * client, csString spellName) --- 291,297 ---- psServer::CharacterLoader.SaveCharacterData(client->GetCharacterData(),client->GetActor()); + SendSpellBook(client); + } void psSpellManager::Cast(Client * client, csString spellName) *************** *** 305,309 **** { psSystemMessage newmsg(client->GetClientNum(),MSG_INFO, ! "You can't cast this spell!"); SendMessage(newmsg.msg); return; --- 302,314 ---- { psSystemMessage newmsg(client->GetClientNum(),MSG_INFO, ! "You can't cast %s!",spellName.GetData()); ! SendMessage(newmsg.msg); ! return; ! } ! ! if (!spell->HaveGlyphsToCast(client->GetCharacterData()->GetGlyphList())) ! { ! psSystemMessage newmsg(client->GetClientNum(),MSG_INFO, ! "You don't have the glyphs to cast %s!",spellName.GetData()); SendMessage(newmsg.msg); return; *************** *** 346,349 **** --- 351,362 ---- } + void psSpellManager::SendSpellBook(Client * client) + { + csString buff = client->GetCharacterData()->GetXMLSpellList(); + + psGUISpellBookMessage newmsg(client->GetClientNum(),psGUISpellBookMessage::SPELL_LIST,buff); + SendMessage(newmsg.msg); + } + void psSpellManager::SendGlyphs( Client * client) *************** *** 397,405 **** csArray<psGlyph*> assembly = glyphList->GetAssemblyList(); - for (int i = 0; i < assembly.Length(); i++) - { - printf("assembly%i: %s\n",i,assembly[i]->GetName()); - } - CacheManager::SpellIterator loop = psServer::cachemanager.GetSpellIterator(); --- 410,413 ---- *************** *** 409,422 **** { p = loop.Next(); - printf("Spell %s: ",p->GetName().GetData()); if (p->MatchGlyphs(assembly)) { - printf("Spell found\n"); - // Combination of glyphs correct return p; } - printf("\n"); } --- 417,426 ---- *************** *** 454,461 **** void psSpellManager::HandleSpellEvent(psSpellGameEvent *event) { ! if (!event->spell->Effect(this, event->caster, event->target)) { ! psSystemMessage newmsg(event->caster->GetClientNum(),MSG_INFO, ! "Spell effect fails for %s",event->spell->GetName().GetData()); SendMessage(newmsg.msg); } --- 458,474 ---- void psSpellManager::HandleSpellEvent(psSpellGameEvent *event) { ! csString spellText, effectCommand; ! ! int effect = event->spell->Effect(event->caster, event->target, &spellText, &effectCommand); ! if (effect) { ! ! psSpellEffectMessage newmsg(0,effect,effectCommand); ! Broadcast(newmsg.msg); ! } ! ! if (spellText != "") ! { ! psSystemMessage newmsg(event->caster->GetClientNum(),MSG_INFO, spellText); SendMessage(newmsg.msg); } *************** *** 473,551 **** SendGlyphs(event->purifyer); } - - - /*-------------------------------------------------------------*/ - - /* - psSpell::psSpell(int id, csString name, int way, int realm, - csTicks casting_duration, - csString effect, csTicks effect_duration, - csString effect_particle_system, csString effect_particle_script, - csString image, csString description ) - :id(id),name(name),way(way),realm(realm), - casting_duration(casting_duration), - effect(effect),effect_duration(effect_duration), - effect_particle_system(effect_particle_system), - effect_particle_script(effect_particle_script), - image(image),description(description) - { - } - */ - - - bool psSpell::Effect(psSpellManager * spellManager, Client * caster, celPSObject * target) - { - bool result = true; - csArray<csString> effects = psSplitt(effect,';'); - for (int i = 0; i < effects.Length(); i++) - { - printf("Spell effect %s on %s\n",effects[i].GetData(),target->GetName()); - if (GetWordNumber(effects[i],1) == "HP") - { - float adjust = atof(GetWordNumber(effects[i],2)); - psCharacter *targetData = target->GetCharacterData(); - if (targetData) - { - targetData->AdjustHitPoints(adjust); - psSystemMessage newmsg(caster->GetClientNum(),MSG_INFO, - "Spell %s heal %s with %.0f HP",GetName().GetData(),target->GetName(),adjust); - spellManager->SendMessage(newmsg.msg); - } - } - } - - if (effect_particle_system != "") - { - int effect = psSpellEffectMessage::EXPLOSION; - - if (effect_particle_system == "explosion") - { - effect = psSpellEffectMessage::EXPLOSION; - - } else if (effect_particle_system == "spiral") - { - effect = psSpellEffectMessage::SPIRAL; - } else if (effect_particle_system == "ball") - { - effect = psSpellEffectMessage::BALL; - } else if (effect_particle_system == "fountain") - { - effect = psSpellEffectMessage::FOUNTAIN; - } else if (effect_particle_system == "emitter") - { - effect = psSpellEffectMessage::EMITTER; - } - - csString xml; - xml.Format("<EFFECT ENTITY=\"%d\" DURATION=\"%d\">%s</EFFECT>", - target->GetEntity()->GetID(),effect_duration,effect_particle_script.GetData()); - psSpellEffectMessage newmsg(0,effect,xml); - spellManager->Broadcast(newmsg.msg); - } - - - return result; - } - /*-------------------------------------------------------------*/ --- 486,489 ---- Index: spellmanager.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/spellmanager.h,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** spellmanager.h 12 Aug 2003 23:10:32 -0000 1.15 --- spellmanager.h 14 Aug 2003 19:52:12 -0000 1.16 *************** *** 49,59 **** void HandleSpellBook(Client * client, psGUISpellBookMessage & msg); void HandleGlyph(Client * client, psGUIGlyphMessage & msg); void SaveSpell(Client * client, csString spellName); void Cast(Client * client, csString spellName); - void StartPurifying(Client * client); - void StartPurifying(Client * client, int glyphSlot); psGlyphList* GetGlyphList(Client * client); void SendGlyphs(Client * client); ! void SendGlyphs(int clientNum); psSpell* VerifySpell(Client * client); --- 49,60 ---- void HandleSpellBook(Client * client, psGUISpellBookMessage & msg); void HandleGlyph(Client * client, psGUIGlyphMessage & msg); + void SaveSpell(Client * client, csString spellName); void Cast(Client * client, csString spellName); psGlyphList* GetGlyphList(Client * client); void SendGlyphs(Client * client); ! void SendSpellBook(Client * client); ! void StartPurifying(Client * client); ! void StartPurifying(Client * client, int glyphSlot); psSpell* VerifySpell(Client * client); |