From: <mg...@us...> - 2008-12-07 03:04:12
|
Revision: 2633 http://planeshift.svn.sourceforge.net/planeshift/?rev=2633&view=rev Author: mgist Date: 2008-12-07 03:04:10 +0000 (Sun, 07 Dec 2008) Log Message: ----------- - Removed thing plugins. Modified Paths: -------------- trunk/src/npcclient/Jamfile trunk/src/server/Jamfile Modified: trunk/src/npcclient/Jamfile =================================================================== --- trunk/src/npcclient/Jamfile 2008-12-06 14:28:47 UTC (rev 2632) +++ trunk/src/npcclient/Jamfile 2008-12-07 03:04:10 UTC (rev 2633) @@ -81,8 +81,6 @@ sprcal3d sprcal3dldr stdrep - thing - thingldr vfs xmlread xmlshader Modified: trunk/src/server/Jamfile =================================================================== --- trunk/src/server/Jamfile 2008-12-06 14:28:47 UTC (rev 2632) +++ trunk/src/server/Jamfile 2008-12-07 03:04:10 UTC (rev 2633) @@ -42,7 +42,6 @@ sprcal3d sprcal3dldr stdrep - thing vfs xmlread xmlshader This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2008-12-08 00:10:19
|
Revision: 2643 http://planeshift.svn.sourceforge.net/planeshift/?rev=2643&view=rev Author: mgist Date: 2008-12-08 00:10:12 +0000 (Mon, 08 Dec 2008) Log Message: ----------- - Some renaming to MaterialManager methods. - Added shader support for equipment. Modified Paths: -------------- trunk/src/client/charapp.cpp trunk/src/client/psengine.cpp trunk/src/client/psengine.h trunk/src/client/weather.cpp trunk/src/common/engine/materialmanager.cpp trunk/src/common/engine/materialmanager.h Modified: trunk/src/client/charapp.cpp =================================================================== --- trunk/src/client/charapp.cpp 2008-12-07 22:23:04 UTC (rev 2642) +++ trunk/src/client/charapp.cpp 2008-12-08 00:10:12 UTC (rev 2643) @@ -82,7 +82,7 @@ csString materialParsed = ParseStrings("", faceMaterial); csString textureParsed = ParseStrings("", faceTexture); - iMaterialWrapper* material = MaterialManager::GetSingletonPtr()->MissingMaterial(materialParsed, textureParsed); + iMaterialWrapper* material = MaterialManager::GetSingletonPtr()->LoadMaterial(materialParsed, textureParsed); if ( !material ) { @@ -260,7 +260,7 @@ csString materialNameParsed = ParseStrings(part, material); csString textureNameParsed = ParseStrings(part, texture); - iMaterialWrapper* material = MaterialManager::GetSingletonPtr()->MissingMaterial(materialNameParsed, textureNameParsed ); + iMaterialWrapper* material = MaterialManager::GetSingletonPtr()->LoadMaterial(materialNameParsed, textureNameParsed ); if ( !material ) { // Not necisarily an error; this texture may just not exist for this character, yet @@ -450,7 +450,7 @@ csString meshNameParsed = ParseStrings(part, meshName); csString textureNameParsed = ParseStrings(part, textureName); - iMaterialWrapper* material = MaterialManager::GetSingletonPtr()->MissingMaterial( meshNameParsed, textureNameParsed ); + iMaterialWrapper* material = MaterialManager::GetSingletonPtr()->LoadMaterial( meshNameParsed, textureNameParsed ); if ( !material ) { // Not necisarily an error; this texture may just not exist for this character, yet Modified: trunk/src/client/psengine.cpp =================================================================== --- trunk/src/client/psengine.cpp 2008-12-07 22:23:04 UTC (rev 2642) +++ trunk/src/client/psengine.cpp 2008-12-08 00:10:12 UTC (rev 2643) @@ -309,6 +309,8 @@ object_reg->Unregister ((iSoundManager*)soundmanager, "iSoundManager"); delete options; + + delete materialmanager; } // ---------------------------------------------------------------------------- @@ -566,7 +568,7 @@ unloadLast = GetConfig()->GetBool("PlaneShift.Client.Loading.UnloadLast", true); - materialmanager.AttachNew(new MaterialManager(object_reg, preloadModels)); + materialmanager = new MaterialManager(object_reg, preloadModels, GetGFXFeatures()); if(preloadModels) { Modified: trunk/src/client/psengine.h =================================================================== --- trunk/src/client/psengine.h 2008-12-07 22:23:04 UTC (rev 2642) +++ trunk/src/client/psengine.h 2008-12-08 00:10:12 UTC (rev 2643) @@ -382,7 +382,7 @@ csRef<ActionHandler> actionhandler; csRef<ZoneHandler> zonehandler; ///< Region/map file memory manager. csRef<psCal3DCallbackLoader> cal3DCallbackLoader; - csRef<MaterialManager> materialmanager; ///< Handles loading of materials/textures. + MaterialManager* materialmanager; ///< Handles loading of materials/textures. psClientCharManager* charmanager; ///< Holds the charactermanager GUIHandler* guiHandler; psCharController* charController; Modified: trunk/src/client/weather.cpp =================================================================== --- trunk/src/client/weather.cpp 2008-12-07 22:23:04 UTC (rev 2642) +++ trunk/src/client/weather.cpp 2008-12-08 00:10:12 UTC (rev 2643) @@ -214,7 +214,7 @@ float speed = 5; // Attempt to fetch material. - iMaterialWrapper* mat = MaterialManager::GetSingletonPtr()->MissingMaterial(matname, "/planeshift/art/effects/raindrop.dds"); + iMaterialWrapper* mat = MaterialManager::GetSingletonPtr()->LoadMaterial(matname, "/planeshift/art/effects/raindrop.dds"); if (!mat) { Bug2("Can't find material '%s' in memory for rain!", matname); @@ -374,7 +374,7 @@ float speed = 1.5f; // Attempt to fetch material. - iMaterialWrapper* mat = MaterialManager::GetSingletonPtr()->MissingMaterial(matname, "/planeshift/art/effects/snow.dds"); + iMaterialWrapper* mat = MaterialManager::GetSingletonPtr()->LoadMaterial(matname, "/planeshift/art/effects/snow.dds"); if (!mat) { Bug2("Can't find material '%s' in memory for snow!", matname); Modified: trunk/src/common/engine/materialmanager.cpp =================================================================== --- trunk/src/common/engine/materialmanager.cpp 2008-12-07 22:23:04 UTC (rev 2642) +++ trunk/src/common/engine/materialmanager.cpp 2008-12-08 00:10:12 UTC (rev 2643) @@ -27,7 +27,7 @@ #include "util/strutil.h" #include "globals.h" -MaterialManager::MaterialManager(iObjectRegistry* _object_reg, bool _keepModels) : scfImplementationType (this) +MaterialManager::MaterialManager(iObjectRegistry* _object_reg, bool _keepModels, uint gfxFeatures) : gfxFeatures(gfxFeatures) { object_reg = _object_reg; csRef<iGraphics3D> g3d = csQueryRegistry<iGraphics3D> (object_reg); @@ -36,26 +36,80 @@ loader = csQueryRegistry<iThreadedLoader> (object_reg); vfs = csQueryRegistry<iVFS> (object_reg); keepModels = _keepModels; + strings = csQueryRegistryTagInterface<iShaderVarStringSet>(object_reg, "crystalspace.shadervar.stringset"); } -iMaterialWrapper* MaterialManager::MissingMaterial(const char *name, const char *filename) +iMaterialWrapper* MaterialManager::LoadMaterial(const char *name, const char *filename) { iMaterialWrapper* materialWrap = engine->GetMaterialList()->FindByName(name); if(!materialWrap) { // Check that the texture exists. - if (!vfs->Exists(filename)) + if(!vfs->Exists(filename)) return NULL; - iTextureWrapper* texture = MissingTexture(name, filename); + // Load base texture. + iTextureWrapper* texture = LoadTexture(name, filename); + // Load base material. csRef<iMaterial> material (engine->CreateBaseMaterial(texture)); materialWrap = engine->GetMaterialList()->NewMaterial(material, name); + + // Check for shader maps. + if(gfxFeatures & useAdvancedShaders) + { + csString shadermap = filename; + filename = shadermap.Truncate(shadermap.Length()-4); + + // Normal map + shadermap = csString(filename).Append("_n.dds"); + if(vfs->Exists(shadermap)) + { + iTextureWrapper* t = LoadTexture(shadermap, shadermap, "normalmap"); + csShaderVariable* shadervar = new csShaderVariable(); + shadervar->SetName(strings->Request("tex normal compressed")); + shadervar->SetValue(t); + material->AddVariable(shadervar); + } + + // Height map + shadermap = csString(filename).Append("_h.dds"); + if(vfs->Exists(shadermap)) + { + iTextureWrapper* t = LoadTexture(shadermap, shadermap); + csShaderVariable* shadervar = new csShaderVariable(); + shadervar->SetName(strings->Request("tex height")); + shadervar->SetValue(t); + material->AddVariable(shadervar); + } + + // Spec map + shadermap = csString(filename).Append("_s.dds"); + if(vfs->Exists(shadermap)) + { + iTextureWrapper* t = LoadTexture(shadermap, shadermap); + csShaderVariable* shadervar = new csShaderVariable(); + shadervar->SetName(strings->Request("tex specular")); + shadervar->SetValue(t); + material->AddVariable(shadervar); + } + + // AO map + shadermap = csString(filename).Append("_ao.dds"); + if(vfs->Exists(shadermap)) + { + iTextureWrapper* t = LoadTexture(shadermap, shadermap); + csShaderVariable* shadervar = new csShaderVariable(); + shadervar->SetName(strings->Request("tex ambient occlusion")); + shadervar->SetValue(t); + material->AddVariable(shadervar); + } + } } return materialWrap; } -iTextureWrapper* MaterialManager::MissingTexture(const char *name, const char *filename) +iTextureWrapper* MaterialManager::LoadTexture(const char *name, const char *filename, const char* className) { // name is the material name; blah.dds // filename will be /planeshift/blah/blah.dds @@ -75,6 +129,10 @@ csRef<iThreadReturn> itr = loader->LoadTexture(name, filename, CS_TEXTURE_3D, txtmgr, true, false); itr->Wait(); texture = scfQueryInterfaceSafe<iTextureWrapper>(itr->GetResultRefPtr()); + if(className) + { + texture->SetTextureClass(className); + } engine->SyncEngineListsNow(loader); } @@ -108,15 +166,15 @@ strcmp (filename + strlen(filename) - 4, ".dds")) continue; - // If this is an icon type texture then not required to load as a - // material. - if ( strstr( filename, "_icon" ) ) + // If this is an icon or shader map texture then we don't load as a material. + if(strstr(filename, "_icon" ) || strstr(filename, "_n." ) || strstr(filename, "_h." ) || + strstr(filename, "_s." ) || strstr(filename, "_ao." )) continue; const char* name = csStrNew(filename); const char* onlyname = PS_GetFileName(name); - if (!MissingMaterial(onlyname,filename)) + if (!LoadMaterial(onlyname,filename)) { delete[] name; return false; @@ -161,42 +219,3 @@ return true; } - -void MaterialManager::UnloadUnusedMaterials() -{ - iMaterialList *matList = engine->GetMaterialList(); - for(int i=0; i<matList->GetCount(); i++) - { - if(matList->Get(i)->GetRefCount() == 1) - { - matList->Remove(i); - i--; - } - } -} - -void MaterialManager::UnloadUnusedTextures() -{ - iTextureList *texList = engine->GetTextureList(); - for(int i=0; i<texList->GetCount(); i++) - { - if(texList->Get(i)->GetRefCount() == 1) - { - texList->Remove(i); - i--; - } - } -} - -void MaterialManager::UnloadUnusedFactories() -{ - iMeshFactoryList *factList = engine->GetMeshFactories(); - for(int i=0; i<factList->GetCount(); i++) - { - if(factList->Get(i)->GetRefCount() == 1) - { - factList->Remove(i); - i--; - } - } -} Modified: trunk/src/common/engine/materialmanager.h =================================================================== --- trunk/src/common/engine/materialmanager.h 2008-12-07 22:23:04 UTC (rev 2642) +++ trunk/src/common/engine/materialmanager.h 2008-12-08 00:10:12 UTC (rev 2643) @@ -31,32 +31,18 @@ struct iObjectRegistry; -class MaterialManager : public scfImplementation1<MaterialManager, iMissingLoaderData>, public Singleton<MaterialManager> +class MaterialManager : public Singleton<MaterialManager> { public: - MaterialManager(iObjectRegistry* _object_reg, bool _keepModels); + MaterialManager(iObjectRegistry* _object_reg, bool _keepModels, uint gfxFeatures); - virtual iMaterialWrapper* MissingMaterial (const char* name, const char* filename); + virtual iMaterialWrapper* LoadMaterial (const char* name, const char* filename); - virtual iTextureWrapper* MissingTexture (const char* name, const char* filename); + virtual iTextureWrapper* LoadTexture (const char* name, const char* filename, const char* className = 0); - virtual iShader* MissingShader (const char* name) { return 0; } - - virtual iMeshFactoryWrapper* MissingFactory (const char* name) { return 0; } - - virtual iMeshWrapper* MissingMesh (const char* name){ return 0; } - - virtual iSector* MissingSector (const char* name) { return 0; } - - virtual iLight* MissingLight (const char* name) { return 0; } - bool PreloadTextures(); bool KeepModels() { return keepModels; } - void UnloadUnusedMaterials(); - void UnloadUnusedTextures(); - void UnloadUnusedFactories(); - private: bool LoadTextureDir(const char *dir); bool keepModels; @@ -65,6 +51,8 @@ csRef<iTextureManager> txtmgr; csRef<iThreadedLoader> loader; csRef<iVFS> vfs; + csRef<iShaderVarStringSet> strings; + uint gfxFeatures; }; #endif // __MATERIAL_MANAGER_H__ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ven...@us...> - 2008-12-08 07:10:12
|
Revision: 2647 http://planeshift.svn.sourceforge.net/planeshift/?rev=2647&view=rev Author: Vengeance2001 Date: 2008-12-08 07:10:10 +0000 (Mon, 08 Dec 2008) Log Message: ----------- Committing parts of a patch submitted by g_remlin with some minor tweaks and typo fixes in different places. Thanks g_remlin! Modified Paths: -------------- trunk/src/client/psclientdr.cpp trunk/src/client/psmovement.cpp trunk/src/common/net/netbase.cpp trunk/src/common/net/netbase.h trunk/src/common/paws/pawsmouse.cpp Modified: trunk/src/client/psclientdr.cpp =================================================================== --- trunk/src/client/psclientdr.cpp 2008-12-08 06:46:05 UTC (rev 2646) +++ trunk/src/client/psclientdr.cpp 2008-12-08 07:10:10 UTC (rev 2647) @@ -89,7 +89,7 @@ psClientDR::celclient = celclient; psClientDR::msghandler = msghandler; - msgstrings = 0; // will get it in a MSGTYPE_MSGSTRINGS message + msgstrings = NULL; // will get it in a MSGTYPE_MSGSTRINGS message msghandler->Subscribe(this,MSGTYPE_DEAD_RECKONING); msghandler->Subscribe(this,MSGTYPE_STATDRUPDATE); Modified: trunk/src/client/psmovement.cpp =================================================================== --- trunk/src/client/psmovement.cpp 2008-12-08 06:46:05 UTC (rev 2646) +++ trunk/src/client/psmovement.cpp 2008-12-08 07:10:10 UTC (rev 2647) @@ -655,12 +655,12 @@ } } - if ( (abs(lastDeltaX) > 150 || abs(lastDeltaY) > 150) ) + if ( fabs(lastDeltaX) > 150 || fabs(lastDeltaY) > 150 ) { // Higher values shouldn't slow down too fast lastDeltaX *= 0.9f; lastDeltaY *= 0.9f; } - else if ( (abs(lastDeltaX) > 5 || abs(lastDeltaY) > 5) ) + else if ( fabs(lastDeltaX) > 5 || fabs(lastDeltaY) > 5 ) { lastDeltaX *= 0.6f; lastDeltaY *= 0.6f; Modified: trunk/src/common/net/netbase.cpp =================================================================== --- trunk/src/common/net/netbase.cpp 2008-12-08 06:46:05 UTC (rev 2646) +++ trunk/src/common/net/netbase.cpp 2008-12-08 07:10:10 UTC (rev 2647) @@ -254,14 +254,14 @@ if (connection && CheckDoublePackets (connection, pkt)) { #ifdef PACKETDEBUG - Debug2(LOG_NET,0,"Droping doubled packet (ID %d)\n", pkt->packet->pktid); + Debug2(LOG_NET,0,"Dropping doubled packet (ID %d)\n", pkt->packet->pktid); #endif return true; } } #ifdef PACKETDEBUG - Debug7(LOG_NET,0,"Recveived Pkt, ID: %d, offset %d, from %d size %d (actual %d) flags %d\n", + Debug7(LOG_NET,0,"Received Pkt, ID: %d, offset %d, from %d size %d (actual %d) flags %d\n", pkt->packet->pktid, pkt->packet->offset, pkt->clientnum, pkt->packet->pktsize,packetlen, pkt->packet->flags); #endif Modified: trunk/src/common/net/netbase.h =================================================================== --- trunk/src/common/net/netbase.h 2008-12-08 06:46:05 UTC (rev 2646) +++ trunk/src/common/net/netbase.h 2008-12-08 07:10:10 UTC (rev 2647) @@ -392,7 +392,7 @@ struct timeval prevTimeout = timeout; /* select returns 0 if timeout, 1 if input available, -1 if error. */ - if (SOCK_SELECT(MAX(mysocket + 1, pipe_fd[0]) + 1, &set, NULL, NULL, &timeout) < 1) + if (SOCK_SELECT(MAX(mysocket, pipe_fd[0]) + 1, &set, NULL, NULL, &timeout) < 1) { timeout = prevTimeout; return 0; Modified: trunk/src/common/paws/pawsmouse.cpp =================================================================== --- trunk/src/common/paws/pawsmouse.cpp 2008-12-08 06:46:05 UTC (rev 2646) +++ trunk/src/common/paws/pawsmouse.cpp 2008-12-08 07:10:10 UTC (rev 2647) @@ -98,7 +98,7 @@ if (g2d->SetMouseCursor (image, &color)) { if (!useOS) - Debug1(LOG_PAWS,NULL,"Using OS Cursor\n"); + Debug1(LOG_PAWS,0,"Using OS Cursor\n"); useOS = true; return; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2008-12-08 07:59:29
|
Revision: 2648 http://planeshift.svn.sourceforge.net/planeshift/?rev=2648&view=rev Author: mgist Date: 2008-12-08 07:59:26 +0000 (Mon, 08 Dec 2008) Log Message: ----------- - Got targeting kinda working again. Modified Paths: -------------- trunk/src/client/pscamera.cpp trunk/src/common/effects/pseffectobjtext2d.cpp Modified: trunk/src/client/pscamera.cpp =================================================================== --- trunk/src/client/pscamera.cpp 2008-12-08 07:10:10 UTC (rev 2647) +++ trunk/src/client/pscamera.cpp 2008-12-08 07:59:26 UTC (rev 2648) @@ -185,6 +185,7 @@ cmdsource->Subscribe("/npcmenu", this); psengine->GetOptions()->RegisterOptionsClass("camera", this); + LoadOptions(); } @@ -893,8 +894,7 @@ return NULL; csVector3 vc, vo, vw; - - csVector2 perspective( x, GetICamera()->GetShiftY() * 2 - y ); + csVector2 perspective( x, GetICamera()->GetShiftY() * psengine->GetG2D()->GetHeight() * 2 - y ); vc = GetICamera()->GetCamera()->InvPerspective( perspective, 1 ); vw = GetICamera()->GetCamera()->GetTransform().This2Other( vc ); @@ -927,8 +927,7 @@ return NULL; csVector3 vc, vo, vw; - - csVector2 perspective( x, GetICamera()->GetShiftY() * 2 - y ); + csVector2 perspective( x, GetICamera()->GetShiftY() * psengine->GetG2D()->GetHeight() * 2 - y ); vc = GetICamera()->GetCamera()->InvPerspective( perspective, 1 ); vw = GetICamera()->GetCamera()->GetTransform().This2Other( vc ); Modified: trunk/src/common/effects/pseffectobjtext2d.cpp =================================================================== --- trunk/src/common/effects/pseffectobjtext2d.cpp 2008-12-08 07:10:10 UTC (rev 2647) +++ trunk/src/common/effects/pseffectobjtext2d.cpp 2008-12-08 07:59:26 UTC (rev 2648) @@ -418,7 +418,7 @@ { // apply perspective sp = view->GetCamera()->Perspective(p); - sp.y = view->GetPerspectiveCamera()->GetShiftY() * 2 - sp.y; + sp.y = view->GetPerspectiveCamera()->GetShiftY() * g2d->GetHeight() * 2 - sp.y; } len = elems.GetSize(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2008-12-10 21:25:29
|
Revision: 2664 http://planeshift.svn.sourceforge.net/planeshift/?rev=2664&view=rev Author: mgist Date: 2008-12-10 21:25:17 +0000 (Wed, 10 Dec 2008) Log Message: ----------- - Added some basics for a future eye colour trait. Modified Paths: -------------- trunk/src/client/charapp.cpp trunk/src/client/charapp.h trunk/src/client/psclientchar.cpp trunk/src/common/net/charmessages.h trunk/src/server/database/mysql/traits.sql Modified: trunk/src/client/charapp.cpp =================================================================== --- trunk/src/client/charapp.cpp 2008-12-10 07:35:39 UTC (rev 2663) +++ trunk/src/client/charapp.cpp 2008-12-10 21:25:17 UTC (rev 2664) @@ -43,7 +43,7 @@ hairMesh = "Hair"; beardMesh = "Beard"; hairAttached = true; - colorSet = false; + hairColorSet = false; state = NULL; stateFactory = NULL; @@ -141,7 +141,7 @@ beardMesh = newPartParsed; } - if ( colorSet ) + if ( hairColorSet ) HairColor(hairShader); } @@ -178,7 +178,7 @@ hairMesh = newPartParsed; } - if ( colorSet ) + if ( hairColorSet ) HairColor(hairShader); } @@ -197,7 +197,7 @@ if ( context_hair ) { - CS::ShaderVarStringID varName = stringSet->Request("colour modulation"); + CS::ShaderVarStringID varName = stringSet->Request("color modulation"); csShaderVariable* var = context_hair->GetVariableAdd(varName); if ( var ) @@ -208,7 +208,7 @@ if ( context_beard ) { - CS::ShaderVarStringID varName = stringSet->Request("colour modulation"); + CS::ShaderVarStringID varName = stringSet->Request("color modulation"); csShaderVariable* var = context_beard->GetVariableAdd(varName); if ( var ) @@ -216,10 +216,13 @@ var->SetValue(hairShader); } } - colorSet = true; + hairColorSet = true; } } +void psCharAppearance::EyeColor(csVector3& color) +{ +} void psCharAppearance::ShowHair(bool show) { @@ -230,7 +233,7 @@ state->AttachCoreMesh(hairMesh); - if (colorSet) + if (hairColorSet) HairColor(hairShader); hairAttached = true; @@ -690,8 +693,8 @@ case PSTRAIT_LOCATION_HAIR_STYLE: { - HairMesh(trait->mesh); - break; + HairMesh(trait->mesh); + break; } @@ -706,12 +709,18 @@ { HairColor(trait->shader); break; - } + } + + case PSTRAIT_LOCATION_EYE_COLOR: + { + EyeColor(trait->shader); + break; + } default: { - Error3("Trait(%d) unkown trait location %d",trait->uid,trait->location); + Error3("Trait(%d) unknown trait location %d",trait->uid,trait->location); result = false; break; } @@ -821,6 +830,6 @@ this->faceMaterial = clone->faceMaterial; this->skinToneSet = clone->skinToneSet; this->hairAttached = clone->hairAttached; - this->colorSet = clone->colorSet; + this->hairColorSet = clone->hairColorSet; this->effectids = clone->effectids; } Modified: trunk/src/client/charapp.h =================================================================== --- trunk/src/client/charapp.h 2008-12-10 07:35:39 UTC (rev 2663) +++ trunk/src/client/charapp.h 2008-12-10 21:25:17 UTC (rev 2664) @@ -73,10 +73,15 @@ */ void BeardMesh(csString& submesh); - /** Set the hair colour of the hair. + /** Set the colour of the hair. * @param shader the R,G,B value of the shader to use on the hair. */ void HairColor(csVector3 &shader); + + /** Set the colour of the eyes. + * @param shader the R,G,B value of the shader to use on the eyes. + */ + void EyeColor(csVector3 &shader); /** Toggle the hair mesh on and off. * @param flag True if we want to show the hair. False if we want to hide it. @@ -219,7 +224,7 @@ bool hairAttached; // Flag if hair is on/off bool beardAttached; // Flag if beard is on/off. - bool colorSet; // Flag if hair colour set. + bool hairColorSet; // Flag if hair colour set. csString faceMaterial; // Default face materail. csArray<SkinToneSet> skinToneSet; // Default skin colours. Modified: trunk/src/client/psclientchar.cpp =================================================================== --- trunk/src/client/psclientchar.cpp 2008-12-10 07:35:39 UTC (rev 2663) +++ trunk/src/client/psclientchar.cpp 2008-12-10 21:25:17 UTC (rev 2664) @@ -156,6 +156,9 @@ if (!strcasecmp(locationstring,"ITEM")) return PSTRAIT_LOCATION_ITEM; + + if (!strcasecmp(locationstring,"EYE_COLOR")) + return PSTRAIT_LOCATION_EYE_COLOR; return PSTRAIT_LOCATION_NONE; } Modified: trunk/src/common/net/charmessages.h =================================================================== --- trunk/src/common/net/charmessages.h 2008-12-10 07:35:39 UTC (rev 2663) +++ trunk/src/common/net/charmessages.h 2008-12-10 21:25:17 UTC (rev 2664) @@ -25,6 +25,7 @@ PSTRAIT_LOCATION_HAIR_COLOR, PSTRAIT_LOCATION_SKIN_TONE, PSTRAIT_LOCATION_ITEM, + PSTRAIT_LOCATION_EYE_COLOR, PSTRAIT_LOCATION_COUNT }; Modified: trunk/src/server/database/mysql/traits.sql =================================================================== --- trunk/src/server/database/mysql/traits.sql 2008-12-10 07:35:39 UTC (rev 2663) +++ trunk/src/server/database/mysql/traits.sql 2008-12-10 21:25:17 UTC (rev 2664) @@ -21,10 +21,16 @@ # # HAIR_COLOR : Hair color is composed of two traits. 1. is used to the beard. 2. is used for the hair. # - Material is the texture that will be the hair/beard. -# - Texture is used to created the material if the material does not exists. +# - Texture is used to create the material if the material does not exist. # - Mesh is the mesh that the material is assigned to. # - Submesh not used. # +# EYE_COLOR : Eye color is a single trait. +# - Material is the texture that will be the eyes. +# - Texture is used to create the material if the material does not exist. +# - Mesh is the mesh that the material is assigned to. +# - Submesh not used. +# # SKIN_TONE : Skin tone is composed of traits. Each trait is applayed to the given mesh. # # ITEM : Traits that are to be applied when a item is equiped. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wel...@us...> - 2008-12-13 09:07:36
|
Revision: 2676 http://planeshift.svn.sourceforge.net/planeshift/?rev=2676&view=rev Author: weltall2 Date: 2008-12-13 09:07:28 +0000 (Sat, 13 Dec 2008) Log Message: ----------- removed some warnings Modified Paths: -------------- trunk/src/client/pscelclient.cpp trunk/src/common/util/eventmanager.cpp Modified: trunk/src/client/pscelclient.cpp =================================================================== --- trunk/src/client/pscelclient.cpp 2008-12-12 20:01:18 UTC (rev 2675) +++ trunk/src/client/pscelclient.cpp 2008-12-13 09:07:28 UTC (rev 2676) @@ -1376,7 +1376,7 @@ if(animName.IsEmpty()) //check if we have an hit else bug the user for the bad data { - Error2("Missing animName from common strings for animid %u!\n", (unsigned long int)animid); + Error2("Missing animName from common strings for animid %lu!\n", (unsigned long int)animid); } else //no need to call this with an empty string in case of bad data so let's skip it in that case { Modified: trunk/src/common/util/eventmanager.cpp =================================================================== --- trunk/src/common/util/eventmanager.cpp 2008-12-12 20:01:18 UTC (rev 2675) +++ trunk/src/common/util/eventmanager.cpp 2008-12-13 09:07:28 UTC (rev 2676) @@ -260,7 +260,7 @@ virtual csString ToString() const { csString str; - str.Format("Delayed message of type : %d" + myMsg->GetType()); + str.Format("Delayed message of type : %d", myMsg->GetType()); return str; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2008-12-13 18:07:55
|
Revision: 2679 http://planeshift.svn.sourceforge.net/planeshift/?rev=2679&view=rev Author: mgist Date: 2008-12-13 18:07:51 +0000 (Sat, 13 Dec 2008) Log Message: ----------- - Some preload improvements. - Removed second, needless view from pawsobjectview. Modified Paths: -------------- trunk/src/client/clientcachemanager.cpp trunk/src/client/clientcachemanager.h trunk/src/client/psengine.cpp trunk/src/common/engine/materialmanager.cpp trunk/src/common/paws/pawsobjectview.cpp trunk/src/common/paws/pawsobjectview.h Modified: trunk/src/client/clientcachemanager.cpp =================================================================== --- trunk/src/client/clientcachemanager.cpp 2008-12-13 12:59:18 UTC (rev 2678) +++ trunk/src/client/clientcachemanager.cpp 2008-12-13 18:07:51 UTC (rev 2679) @@ -152,6 +152,11 @@ return indexEntry; } +void ClientCacheManager::Precache() +{ + psengine->GetEngine()->PrecacheDraw(cache); +} + FactoryIndexEntry* ClientCacheManager::GetFactoryEntry(const char* filename) { // Search for a factory entry with the filename we've passed. Modified: trunk/src/client/clientcachemanager.h =================================================================== --- trunk/src/client/clientcachemanager.h 2008-12-13 12:59:18 UTC (rev 2678) +++ trunk/src/client/clientcachemanager.h 2008-12-13 18:07:51 UTC (rev 2679) @@ -65,6 +65,11 @@ */ FactoryIndexEntry* GetFactoryEntry(const char* filename); + /** + * Calls iEngine::PrecacheDraw on the collection. + */ + void Precache(); + private: /** Loads a new model factory. Modified: trunk/src/client/psengine.cpp =================================================================== --- trunk/src/client/psengine.cpp 2008-12-13 12:59:18 UTC (rev 2678) +++ trunk/src/client/psengine.cpp 2008-12-13 18:07:51 UTC (rev 2679) @@ -1490,6 +1490,8 @@ if (modelnames.GetSize()-1 < modelToLoad) { BuildFactoryList(); + engine->SyncEngineListsNow(loader); + cachemanager->Precache(); Debug1(LOG_ADMIN,0, "Preloading complete"); delete paws->FindWidget("SplashWindow"); Modified: trunk/src/common/engine/materialmanager.cpp =================================================================== --- trunk/src/common/engine/materialmanager.cpp 2008-12-13 12:59:18 UTC (rev 2678) +++ trunk/src/common/engine/materialmanager.cpp 2008-12-13 18:07:51 UTC (rev 2679) @@ -217,5 +217,7 @@ if (!LoadTextureDir("/planeshift/food/")) return false; + engine->SyncEngineListsNow(loader); + return true; } Modified: trunk/src/common/paws/pawsobjectview.cpp =================================================================== --- trunk/src/common/paws/pawsobjectview.cpp 2008-12-13 12:59:18 UTC (rev 2678) +++ trunk/src/common/paws/pawsobjectview.cpp 2008-12-13 18:07:51 UTC (rev 2679) @@ -170,21 +170,6 @@ return false; } - meshSector = engine->CreateSector( realName ); - - iLightList* lightList = meshSector->GetLights(); - csRef<iLight> light = engine->CreateLight(NULL, csVector3(-3,4,-3),10, - csColor(0.86F,0.87F,0.6F), CS_LIGHT_STATIC); - light->SetAttenuationMode( CS_ATTN_NONE ); - lightList->Add( light ); - - meshView = csPtr<iView> (new csView( engine, PawsManager::GetSingleton().GetGraphics3D() )); - meshView->GetCamera()->SetSector(meshSector); - meshView->GetCamera()->GetTransform().SetOrigin(csVector3(0,1,-distance)); - - meshView->SetRectangle(screenFrame.xmin, screenFrame.ymin, - screenFrame.Width(),screenFrame.Height()); - view = csPtr<iView> (new csView( engine, PawsManager::GetSingleton().GetGraphics3D() )); view->GetCamera()->SetSector(stage); view->GetCamera()->GetTransform().SetOrigin(csVector3(0,1,-distance)); @@ -224,8 +209,7 @@ if(wrapper) { - iSector* sector = loadedMap ? meshSector : stage; - object = engine->CreateMeshWrapper (wrapper, "PaperDoll", sector, csVector3(0,0,0) ); + object = engine->CreateMeshWrapper (wrapper, "PaperDoll", stage, csVector3(0,0,0) ); } } @@ -332,24 +316,6 @@ view->Draw(); - if ( loadedMap ) - { - og3d = meshView->GetContext(); - - meshView->SetContext(PawsManager::GetSingleton().GetGraphics3D()); - - meshView->SetRectangle(screenFrame.xmin, - PawsManager::GetSingleton().GetGraphics3D()->GetHeight() - screenFrame.ymax , - screenFrame.Width(), screenFrame.Height()); - - meshView->GetPerspectiveCamera()->SetPerspectiveCenter((float)(screenFrame.xmin+(screenFrame.Width() >> 1))/graphics2D->GetWidth(), - 1-(float)(screenFrame.ymin+(screenFrame.Height() >> 1))/graphics2D->GetHeight()); - - meshView->GetCamera()->GetTransform().SetOrigin(cameraPosition); - meshView->GetCamera()->GetTransform().LookAt(lookingAt, csVector3(0, 1, 0)); - meshView->Draw(); - } - PawsManager::GetSingleton().GetGraphics3D()->BeginDraw( CSDRAW_2DGRAPHICS ); view->SetContext( og3d ); @@ -439,24 +405,6 @@ view->Draw(); - if ( loadedMap ) - { - og3d = meshView->GetContext(); - - meshView->SetContext(PawsManager::GetSingleton().GetGraphics3D()); - - meshView->SetRectangle(screenFrame.xmin, - PawsManager::GetSingleton().GetGraphics3D()->GetHeight() - screenFrame.ymax , - screenFrame.Width(), screenFrame.Height()); - - meshView->GetPerspectiveCamera()->SetPerspectiveCenter((float)(screenFrame.xmin+(screenFrame.Width() >> 1))/graphics2D->GetWidth(), - 1-(float)(screenFrame.ymin+(screenFrame.Height() >> 1))/graphics2D->GetHeight()); - - meshView->GetCamera()->GetTransform().SetOrigin(camera); - meshView->GetCamera()->GetTransform().LookAt(objectPos - camera + cameraMod, csVector3(0, 1, 0)); - meshView->Draw(); - } - PawsManager::GetSingleton().GetGraphics3D()->BeginDraw( CSDRAW_2DGRAPHICS ); view->SetContext( og3d ); Modified: trunk/src/common/paws/pawsobjectview.h =================================================================== --- trunk/src/common/paws/pawsobjectview.h 2008-12-13 12:59:18 UTC (rev 2678) +++ trunk/src/common/paws/pawsobjectview.h 2008-12-13 18:07:51 UTC (rev 2679) @@ -141,9 +141,6 @@ static int idName; csString realName; - csRef<iSector> meshSector; - csRef<iView> meshView; - void RotateDef(); // Used to reset to the values given by the controlling widget void RotateTemp(int speed,float radians); // Used to for example stop the rotate but not write the def values This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2008-12-13 18:50:34
|
Revision: 2681 http://planeshift.svn.sourceforge.net/planeshift/?rev=2681&view=rev Author: mgist Date: 2008-12-13 18:50:30 +0000 (Sat, 13 Dec 2008) Log Message: ----------- - Cleaned up the Clear() function in pawsobjectview and calls to it. Modified Paths: -------------- trunk/src/client/gui/pawscharcreatemain.cpp trunk/src/client/gui/pawscharpick.cpp trunk/src/common/paws/pawsobjectview.cpp Modified: trunk/src/client/gui/pawscharcreatemain.cpp =================================================================== --- trunk/src/client/gui/pawscharcreatemain.cpp 2008-12-13 18:48:50 UTC (rev 2680) +++ trunk/src/client/gui/pawscharcreatemain.cpp 2008-12-13 18:50:30 UTC (rev 2681) @@ -994,7 +994,6 @@ void pawsCreationMain::UpdateRace(int id) { - view->Clear(); loaded = false; int raceCP = createManager->GetRaceCP( id ); lastRaceID = id; Modified: trunk/src/client/gui/pawscharpick.cpp =================================================================== --- trunk/src/client/gui/pawscharpick.cpp 2008-12-13 18:48:50 UTC (rev 2680) +++ trunk/src/client/gui/pawscharpick.cpp 2008-12-13 18:50:30 UTC (rev 2681) @@ -470,7 +470,6 @@ else { // Show the model for the selected character. - view->Clear(); loaded = false; view->Show(); CheckMeshLoad(); @@ -514,7 +513,6 @@ else { // Show the model for the selected character. - view->Clear(); loaded = false; view->Show(); CheckMeshLoad(); Modified: trunk/src/common/paws/pawsobjectview.cpp =================================================================== --- trunk/src/common/paws/pawsobjectview.cpp 2008-12-13 18:48:50 UTC (rev 2680) +++ trunk/src/common/paws/pawsobjectview.cpp 2008-12-13 18:50:30 UTC (rev 2681) @@ -130,14 +130,14 @@ stage = engine->FindSector( sector ); - // Create/Get collection and clear it in case it already existed. - iCollection* col = engine->CreateCollection(realName); - if ( !stage ) { csRef<iDocumentSystem> xml ( csQueryRegistry<iDocumentSystem> (PawsManager::GetSingleton().GetObjectRegistry())); + // Create/Get collection + iCollection* col = engine->CreateCollection(realName); + csRef<iDocument> doc = xml->CreateDocument(); csString filename = map; filename.Append("/world"); @@ -215,8 +215,6 @@ void pawsObjectView::View( iMeshWrapper* wrapper ) { - Clear(); - if(wrapper) { View(wrapper->GetFactory()); @@ -464,9 +462,10 @@ void pawsObjectView::Clear() { - if(object) + iMeshWrapper* mesh = stage->GetMeshes()->FindByName("PaperDoll"); + if(mesh) { - object->GetMovable()->ClearSectors(); - engine->GetMeshes()->Remove(object); + stage->GetMeshes()->Remove(mesh); + engine->GetMeshes()->Remove(mesh); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wel...@us...> - 2008-12-20 09:58:51
|
Revision: 2723 http://planeshift.svn.sourceforge.net/planeshift/?rev=2723&view=rev Author: weltall2 Date: 2008-12-20 09:58:48 +0000 (Sat, 20 Dec 2008) Log Message: ----------- committed the protocol breakers changes Modified Paths: -------------- trunk/src/common/net/messages.cpp trunk/src/common/net/messages.h trunk/src/server/usermanager.cpp Modified: trunk/src/common/net/messages.cpp =================================================================== --- trunk/src/common/net/messages.cpp 2008-12-20 09:21:25 UTC (rev 2722) +++ trunk/src/common/net/messages.cpp 2008-12-20 09:58:48 UTC (rev 2723) @@ -4985,6 +4985,7 @@ const csString& race2s, const csString& desc2s, const csArray<NetworkDetailSkill>& skills2s, + const csString& desc_ooc, const csString& creationinfo, const csString& requestor) { @@ -4994,7 +4995,7 @@ size += sizeof(uint32_t) + skills2s[x].text.Length()+1; } - msg.AttachNew(new MsgEntry( desc2s.Length()+1 + sizeof(gender2s) + name2s.Length() + 1 + race2s.Length() + 1 + creationinfo.Length() + 1 + requestor.Length() + 1 + size)); + msg.AttachNew(new MsgEntry( desc2s.Length()+1 + sizeof(gender2s) + name2s.Length() + 1 + race2s.Length() + 1 + desc_ooc.Length() + 1 + creationinfo.Length() + 1 + requestor.Length() + 1 + size)); msg->SetType(MSGTYPE_CHARACTERDETAILS); msg->clientnum = clientnum; @@ -5003,6 +5004,7 @@ msg->Add(gender2s); msg->Add(race2s); msg->Add(desc2s); + msg->Add(desc_ooc); msg->Add(creationinfo); msg->Add(requestor); @@ -5020,6 +5022,7 @@ gender = me->GetUInt16(); race = me->GetStr(); desc = me->GetStr(); + desc_ooc = me->GetStr(); creationinfo = me->GetStr(); requestor = me->GetStr(); uint32_t len = me->GetUInt32(); @@ -5037,8 +5040,8 @@ { csString msgtext; - msgtext.AppendFmt("Name: '%s' Gender: %d Race: '%s' Description: '%s' Requestor: '%s'", - name.GetDataSafe(), gender, race.GetDataSafe(), desc.GetDataSafe(), requestor.GetDataSafe()); + msgtext.AppendFmt("Name: '%s' Gender: %d Race: '%s' Description: '%s' OOC Description: %s Character Creation Info: %s Requestor: '%s'", + name.GetDataSafe(), gender, race.GetDataSafe(), desc.GetDataSafe(), desc_ooc.GetDataSafe(), creationinfo.GetDataSafe(), requestor.GetDataSafe()); for ( size_t x = 0; x < skills.GetSize(); x++ ) { msgtext.AppendFmt(" Skill: '%s' Category: '%d'", Modified: trunk/src/common/net/messages.h =================================================================== --- trunk/src/common/net/messages.h 2008-12-20 09:21:25 UTC (rev 2722) +++ trunk/src/common/net/messages.h 2008-12-20 09:58:48 UTC (rev 2723) @@ -3528,7 +3528,7 @@ }; psCharacterDetailsMessage( int clientnum, const csString& name2s,unsigned short int gender2s,const csString& race2s, - const csString& desc2s, const csArray<NetworkDetailSkill>& skills2s, const csString& creationinfo, const csString& requestor); + const csString& desc2s, const csArray<NetworkDetailSkill>& skills2s, const csString& desc_ooc, const csString& creationinfo, const csString& requestor); psCharacterDetailsMessage( MsgEntry* me ); PSF_DECLARE_MSG_FACTORY(); @@ -3545,6 +3545,7 @@ unsigned short int gender; csString race; csString desc; + csString desc_ooc; csString creationinfo; csArray<NetworkDetailSkill> skills; @@ -3592,18 +3593,21 @@ class psCharacterDescriptionUpdateMessage : public psMessageCracker { public: - psCharacterDescriptionUpdateMessage(csString& newValue) + psCharacterDescriptionUpdateMessage(csString& newValue, bool oocdesc) { - msg.AttachNew(new MsgEntry( newValue.Length() +1 )); + msg.AttachNew(new MsgEntry( newValue.Length() +1 + sizeof(oocdesc) )); msg->SetType(MSGTYPE_CHARDESCUPDATE); + msg->clientnum = 0; msg->Add(newValue); + msg->Add(oocdesc); } psCharacterDescriptionUpdateMessage(MsgEntry *me) { newValue = me->GetStr(); + oocdesc = me->GetBool(); } PSF_DECLARE_MSG_FACTORY(); @@ -3617,6 +3621,7 @@ virtual csString ToString(AccessPointers * access_ptrs); csString newValue; + bool oocdesc; }; //------------------------------------------------------------------------------ Modified: trunk/src/server/usermanager.cpp =================================================================== --- trunk/src/server/usermanager.cpp 2008-12-20 09:21:25 UTC (rev 2722) +++ trunk/src/server/usermanager.cpp 2008-12-20 09:58:48 UTC (rev 2723) @@ -685,6 +685,7 @@ csString desc = charData->GetDescription(); //send creation info only if the player is requesting his info csString creationinfo = isSelf? charData->GetCreationInfo() : ""; + csString desc_ooc = ""; //placeholder csArray<psCharacterDetailsMessage::NetworkDetailSkill> skills; if ( !simple && CacheManager::GetSingleton().GetCommandManager()->Validate(client->GetSecurityLevel(), "view stats") ) @@ -816,7 +817,7 @@ // Finally send the details message psCharacterDetailsMessage detailmsg(client->GetClientNum(), charName, (short unsigned int)gender, raceName, - desc, skills, creationinfo, requestor ); + desc, skills, desc_ooc, creationinfo, requestor ); detailmsg.SendMessage(); } @@ -827,7 +828,11 @@ if (!charData) return; - charData->SetDescription(descUpdate.newValue); + if(descUpdate.oocdesc) + {} //placeholder + else + charData->SetDescription(descUpdate.newValue); + Debug3(LOG_USER, client->GetClientNum(), "Character description updated for %s (%s)\n", charData->GetCharFullName(), ShowID(client->GetAccountID())); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2008-12-22 06:17:13
|
Revision: 2738 http://planeshift.svn.sourceforge.net/planeshift/?rev=2738&view=rev Author: mgist Date: 2008-12-22 06:17:10 +0000 (Mon, 22 Dec 2008) Log Message: ----------- - Fixes for teleport-load and terrain loading. Modified Paths: -------------- trunk/src/client/zonehandler.cpp trunk/src/common/engine/loader.cpp trunk/src/common/engine/loader.h Modified: trunk/src/client/zonehandler.cpp =================================================================== --- trunk/src/client/zonehandler.cpp 2008-12-22 04:00:25 UTC (rev 2737) +++ trunk/src/client/zonehandler.cpp 2008-12-22 06:17:10 UTC (rev 2738) @@ -214,6 +214,8 @@ haveNewPos = true; newPos = msg.pos; + Loader::GetSingleton().UpdatePosition(newPos, sectorToLoad); + if (FindLoadWindow()) { loadWindow->SetAlwaysOnTop(true); Modified: trunk/src/common/engine/loader.cpp =================================================================== --- trunk/src/common/engine/loader.cpp 2008-12-22 04:00:25 UTC (rev 2737) +++ trunk/src/common/engine/loader.cpp 2008-12-22 06:17:10 UTC (rev 2738) @@ -515,8 +515,15 @@ void Loader::UpdatePosition(csVector3& pos, const char* sectorName) { csRef<Sector> sector; - for(size_t i=0; i<sectors.GetSize(); i++) + + // Hack to work around the weird sector stuff we do. + if(csString("SectorWhereWeKeepEntitiesResidingInUnloadedMaps").Compare(sectorName)) { + sector = lastSector; + } + + for(size_t i=0; !sector.IsValid() && i<sectors.GetSize(); i++) + { if(sectors[i]->name.Compare(sectorName)) { sector = sectors[i]; @@ -525,7 +532,10 @@ } if(sector.IsValid()) + { + lastSector = sector; LoadSector(pos, sector); + } } void Loader::LoadSector(csVector3& pos, Sector* sector) @@ -657,6 +667,7 @@ if(mesh->status && mesh->status->IsFinished()) { + vfs->ChDir("/planeshift/maps/"); mesh->object = scfQueryInterface<iMeshWrapper>(mesh->status->GetResultRefPtr()); mesh->object->GetMovable()->SetSector(sector->object); mesh->object->GetMovable()->UpdateMove(); Modified: trunk/src/common/engine/loader.h =================================================================== --- trunk/src/common/engine/loader.h 2008-12-22 04:00:25 UTC (rev 2737) +++ trunk/src/common/engine/loader.h 2008-12-22 06:17:10 UTC (rev 2738) @@ -83,8 +83,7 @@ csRef<iStringSet> strings; uint gfxFeatures; - csVector3 curPos; - csString curSector; + csRef<Sector> lastSector; csRefArray<MeshObj> loadingMeshes; csRefArray<Portal> loadedPortals; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2008-12-23 02:18:19
|
Revision: 2743 http://planeshift.svn.sourceforge.net/planeshift/?rev=2743&view=rev Author: mgist Date: 2008-12-23 01:34:35 +0000 (Tue, 23 Dec 2008) Log Message: ----------- - Loader changes; Fixes to portal and mesh loading, added a search for disconnected sectors, performance improvements. Modified Paths: -------------- trunk/src/client/pscelclient.cpp trunk/src/client/pscelclient.h trunk/src/client/psengine.cpp trunk/src/client/zonehandler.cpp trunk/src/common/engine/loader.cpp trunk/src/common/engine/loader.h Modified: trunk/src/client/pscelclient.cpp =================================================================== --- trunk/src/client/pscelclient.cpp 2008-12-23 01:23:34 UTC (rev 2742) +++ trunk/src/client/pscelclient.cpp 2008-12-23 01:34:35 UTC (rev 2743) @@ -284,7 +284,7 @@ SetMainActor( local_player ); // Now that we know where we are, trigger a world load around us. - Loader::GetSingleton().UpdatePosition(mesg.pos, mesg.sectorName); + Loader::GetSingleton().UpdatePosition(mesg.pos, mesg.sectorName, true); // This triggers the server to update our proxlist local_player->SendDRUpdate(PRIORITY_LOW,GetClientDR()->GetMsgStrings()); @@ -793,7 +793,7 @@ if(local_player) { Loader::GetSingleton().UpdatePosition(local_player->Pos(), - local_player->GetSector()->QueryObject()->GetName()); + local_player->GetSector()->QueryObject()->GetName(), false); } shadowManager->UpdateShadows(); @@ -1425,7 +1425,7 @@ return linmove->GetVelocity(); } -csVector3 GEMClientActor::Pos() +csVector3& GEMClientActor::Pos() { if(linmove) linmove->GetLastPosition (pos, yrot, sector); Modified: trunk/src/client/pscelclient.h =================================================================== --- trunk/src/client/pscelclient.h 2008-12-23 01:23:34 UTC (rev 2742) +++ trunk/src/client/pscelclient.h 2008-12-23 01:34:35 UTC (rev 2743) @@ -433,7 +433,7 @@ */ psClientVitals* GetVitalMgr() { return vitalManager; } - csVector3 Pos(); + csVector3& Pos(); csVector3 Rot(); iSector *GetSector(); Modified: trunk/src/client/psengine.cpp =================================================================== --- trunk/src/client/psengine.cpp 2008-12-23 01:23:34 UTC (rev 2742) +++ trunk/src/client/psengine.cpp 2008-12-23 01:34:35 UTC (rev 2743) @@ -570,7 +570,7 @@ threadedLoading = !psengine->GetConfig()->GetBool("ThreadManager.AlwaysRunNow"); Loader* loader = new Loader(); - Loader::GetSingleton().Init(object_reg, preloadModels, gfxFeatures, 100); + Loader::GetSingleton().Init(object_reg, preloadModels, gfxFeatures, 500); if(threadedLoading) { Modified: trunk/src/client/zonehandler.cpp =================================================================== --- trunk/src/client/zonehandler.cpp 2008-12-23 01:23:34 UTC (rev 2742) +++ trunk/src/client/zonehandler.cpp 2008-12-23 01:34:35 UTC (rev 2743) @@ -207,14 +207,15 @@ FlagRegions(zone); } - if (psengine->ThreadedLoading() || world->NeedsLoading(zone->transitional)) + if ((psengine->ThreadedLoading() && !psengine->IsGameLoaded()) || + !psengine->ThreadedLoading() && world->NeedsLoading(zone->transitional)) { SetMapLoadNeeded(true); sectorToLoad = msg.newSector; haveNewPos = true; newPos = msg.pos; - Loader::GetSingleton().UpdatePosition(newPos, sectorToLoad); + Loader::GetSingleton().UpdatePosition(newPos, sectorToLoad, true); if (FindLoadWindow()) { Modified: trunk/src/common/engine/loader.cpp =================================================================== --- trunk/src/common/engine/loader.cpp 2008-12-23 01:23:34 UTC (rev 2742) +++ trunk/src/common/engine/loader.cpp 2008-12-23 01:34:35 UTC (rev 2743) @@ -23,6 +23,7 @@ #include <csutil/scanstr.h> #include <iengine/movable.h> #include <iengine/portal.h> +#include <imesh/object.h> #include <iutil/stringarray.h> #include <iutil/object.h> #include <ivaria/collider.h> @@ -44,6 +45,7 @@ vfs = csQueryRegistry<iVFS> (object_reg); svstrings = csQueryRegistryTagInterface<iShaderVarStringSet>(object_reg, "crystalspace.shader.variablenameset"); strings = csQueryRegistryTagInterface<iStringSet>(object_reg, "crystalspace.shared.stringset"); + cdsys = csQueryRegistry<iCollideSystem> (object_reg); csRef<iGraphics3D> g3d = csQueryRegistry<iGraphics3D> (object_reg); txtmgr = g3d->GetTextureManager(); @@ -276,6 +278,7 @@ { csRef<iDocumentNode> node2 = nodeItr2->Next(); csRef<MeshObj> m = csPtr<MeshObj>(new MeshObj(node2->GetAttributeValue("name"), node2)); + m->sector = s; if(node2->GetNode("move")) { @@ -413,7 +416,7 @@ } csRef<iDocumentNodeIterator> nodeItr3 = node2->GetNodes("v"); - p->num_vertices = (int)nodeItr3->GetEndPosition(); + p->num_vertices = (int)nodeItr3->GetEndPosition()-2; p->vertices = new csVector3[p->num_vertices]; int i = 0; while(nodeItr3->HasNext()) @@ -512,10 +515,24 @@ } } -void Loader::UpdatePosition(csVector3& pos, const char* sectorName) +void Loader::UpdatePosition(const csVector3& pos, const char* sectorName, bool force) { + // Check already loading meshes. + for(size_t i=0; i<loadingMeshes.GetSize(); i++) + { + LoadMesh(loadingMeshes[i]); + } + + if(!force) + { + // Check if we've moved. + if(lastSector.IsValid() && lastSector->name.Compare(sectorName) && csVector3(lastPos - pos).Norm() < loadRange/10) + { + return; + } + } + csRef<Sector> sector; - // Hack to work around the weird sector stuff we do. if(csString("SectorWhereWeKeepEntitiesResidingInUnloadedMaps").Compare(sectorName)) { @@ -533,13 +550,92 @@ if(sector.IsValid()) { + LoadSector(pos, sector); + if(lastSector != sector) + { + CleanDisconnectedSectors(sector); + } + lastPos = pos; lastSector = sector; - LoadSector(pos, sector); } } -void Loader::LoadSector(csVector3& pos, Sector* sector) +void Loader::CleanDisconnectedSectors(Sector* sector) { + // Create a list of connectedSectors; + csRefArray<Sector> connectedSectors; + FindConnectedSectors(connectedSectors, sector); + + // Check for disconnected sectors. + for(size_t i=0; i<sectors.GetSize(); i++) + { + if(sectors[i]->object.IsValid() && connectedSectors.Find(sectors[i]) == csArrayItemNotFound) + { + CleanSector(sectors[i]); + } + } +} + +void Loader::FindConnectedSectors(csRefArray<Sector>& connectedSectors, Sector* sector) +{ + if(connectedSectors.Find(sector) != csArrayItemNotFound) + { + return; + } + + connectedSectors.Push(sector); + + for(size_t i=0; i<sector->activePortals.GetSize(); i++) + { + FindConnectedSectors(connectedSectors, sector->activePortals[i]->targetSector); + } +} + +void Loader::CleanSector(Sector* sector) +{ + for(size_t i=0; i<sector->meshes.GetSize(); i++) + { + if(sector->meshes[i]->object.IsValid()) + { + sector->meshes[i]->object->GetMovable()->ClearSectors(); + sector->meshes[i]->object->GetMovable()->UpdateMove(); + engine->GetMeshes()->Remove(sector->meshes[i]->object); + sector->meshes[i]->object.Invalidate(); + --sector->objectCount; + } + } + + for(size_t i=0; i<sector->portals.GetSize(); i++) + { + if(sector->portals[i]->mObject.IsValid()) + { + engine->GetMeshes()->Remove(sector->portals[i]->mObject); + sector->portals[i]->pObject = NULL; + sector->portals[i]->mObject.Invalidate(); + sector->activePortals.Delete(sector->portals[i]); + --sector->objectCount; + } + } + + for(size_t i=0; i<sector->lights.GetSize(); i++) + { + if(sector->lights[i]->object.IsValid()) + { + engine->RemoveLight(sector->lights[i]->object); + sector->lights[i]->object.Invalidate(); + --sector->objectCount; + } + } + + CS_ASSERT_MSG("Error cleaning sector. Sector still has objects!", sector->objectCount == 0); + CS_ASSERT_MSG("Error cleaning sector. Sector is invalid!", sector->object.IsValid()); + + engine->GetSectors()->Remove(sector->object); + sector->object.Invalidate(); +} + +void Loader::LoadSector(const csVector3& pos, Sector* sector) +{ sector->isLoading = true; if(!sector->object.IsValid()) @@ -549,17 +645,11 @@ sector->object->SetVisibilityCullerPlugin(sector->culler); } - // Check already loading meshes. - for(size_t i=0; i<loadingMeshes.GetSize(); i++) - { - LoadMesh(sector, loadingMeshes[i]); - } - // Check other sectors linked to by active portals. - for(size_t i=0; i<loadedPortals.GetSize(); i++) + for(size_t i=0; i<sector->activePortals.GetSize(); i++) { - if(!loadedPortals[i]->targetSector->isLoading) - LoadSector(pos, loadedPortals[i]->targetSector); + if(!sector->activePortals[i]->targetSector->isLoading) + LoadSector(pos, sector->activePortals[i]->targetSector); } for(size_t i=0; i<sector->meshes.GetSize(); i++) @@ -570,7 +660,7 @@ { sector->meshes[i]->loading = true; loadingMeshes.Push(sector->meshes[i]); - LoadMesh(sector, sector->meshes[i]); + LoadMesh(sector->meshes[i]); ++sector->objectCount; } else if(sector->meshes[i]->object.IsValid() && csVector3(sector->meshes[i]->pos - pos).Norm() > loadRange*1.5) @@ -596,7 +686,7 @@ sector->portals[i]->mObject = engine->CreatePortal(sector->portals[i]->name, sector->object, csVector3(0), sector->portals[i]->targetSector->object, sector->portals[i]->vertices, sector->portals[i]->num_vertices, sector->portals[i]->pObject); - loadedPortals.Push(sector->portals[i]); + sector->activePortals.Push(sector->portals[i]); ++sector->objectCount; } else if(sector->portals[i]->mObject.IsValid() && sector->portals[i]->OutOfRange(pos)) @@ -609,7 +699,7 @@ engine->GetMeshes()->Remove(sector->portals[i]->mObject); sector->portals[i]->pObject = NULL; sector->portals[i]->mObject.Invalidate(); - loadedPortals.Delete(sector->portals[i]); + sector->activePortals.Delete(sector->portals[i]); --sector->objectCount; } } @@ -642,7 +732,7 @@ sector->isLoading = false; } -void Loader::LoadMesh(Sector* sector, MeshObj* mesh) +void Loader::LoadMesh(MeshObj* mesh) { bool ready = true; for(size_t i=0; i<mesh->meshfacts.GetSize(); i++) @@ -669,15 +759,11 @@ { vfs->ChDir("/planeshift/maps/"); mesh->object = scfQueryInterface<iMeshWrapper>(mesh->status->GetResultRefPtr()); - mesh->object->GetMovable()->SetSector(sector->object); + engine->SyncEngineListsNow(tloader); + mesh->object->GetMovable()->SetSector(mesh->sector->object); mesh->object->GetMovable()->UpdateMove(); - csRef<iCollideSystem> cdsys = csQueryRegistry<iCollideSystem> (object_reg); - csRef<csColliderWrapper> cw = csColliderHelper::InitializeCollisionWrapper(cdsys, mesh->object); - if(cw) - { - mesh->object->QueryObject()->ObjAdd(cw); - cw->SetObjectParent(mesh->object->QueryObject()); - } + engine->PrecacheMesh(mesh->object); + csColliderHelper::InitializeCollisionWrapper(cdsys, mesh->object); loadingMeshes.Delete(mesh); mesh->loading = false; } @@ -743,7 +829,7 @@ for(size_t i=0; i<material->shadervars.GetSize(); i++) { - if(material->shadervars[i].type = csShaderVariable::TEXTURE) + if(material->shadervars[i].type == csShaderVariable::TEXTURE) { for(size_t j=0; j<material->textures.GetSize(); j++) { @@ -757,7 +843,7 @@ } } } - else if(material->shadervars[i].type = csShaderVariable::VECTOR2) + else if(material->shadervars[i].type == csShaderVariable::VECTOR2) { csShaderVariable* var = mat->GetVariableAdd(svstrings->Request(material->shadervars[i].name)); var->SetType(material->shadervars[i].type); Modified: trunk/src/common/engine/loader.h =================================================================== --- trunk/src/common/engine/loader.h 2008-12-23 01:23:34 UTC (rev 2742) +++ trunk/src/common/engine/loader.h 2008-12-23 01:34:35 UTC (rev 2743) @@ -34,6 +34,7 @@ #include "util/singleton.h" +struct iCollideSystem; struct iObjectRegistry; class Loader : public Singleton<Loader> @@ -46,7 +47,7 @@ iTextureWrapper* LoadTexture (const char* name, const char* filename, const char* className = 0); void PrecacheData(const char* path); - void UpdatePosition(csVector3& pos, const char* sectorName); + void UpdatePosition(const csVector3& pos, const char* sectorName, bool force); bool PreloadTextures(); bool KeepModels() { return keepModels; } @@ -64,8 +65,11 @@ class Portal; class Light; - void LoadSector(csVector3& pos, Sector* sector); - void LoadMesh(Sector* sector, MeshObj* mesh); + void CleanDisconnectedSectors(Sector* sector); + void FindConnectedSectors(csRefArray<Sector>& connectedSectors, Sector* sector); + void CleanSector(Sector* sector); + void LoadSector(const csVector3& pos, Sector* sector); + void LoadMesh(MeshObj* mesh); bool LoadMeshFact(MeshFact* meshfact); bool LoadMaterial(Material* material); bool LoadTexture(Texture* texture); @@ -81,12 +85,13 @@ csRef<iVFS> vfs; csRef<iShaderVarStringSet> svstrings; csRef<iStringSet> strings; + csRef<iCollideSystem> cdsys; uint gfxFeatures; csRef<Sector> lastSector; + csVector3 lastPos; csRefArray<MeshObj> loadingMeshes; - csRefArray<Portal> loadedPortals; csRefArray<Texture> textures; csRefArray<Material> materials; @@ -163,7 +168,7 @@ class Sector : public CS::Utility::FastRefCount<Sector> { public: - Sector(const char* name) : name(name), isLoading(false) + Sector(const char* name) : name(name), isLoading(false), objectCount(0) { ambient = csColor(0.0f); } @@ -176,6 +181,7 @@ csRef<iSector> object; csRefArray<MeshObj> meshes; csRefArray<Portal> portals; + csRefArray<Portal> activePortals; csRefArray<Light> lights; }; @@ -196,6 +202,7 @@ csRefArray<Texture> textures; csRefArray<Material> materials; csRefArray<MeshFact> meshfacts; + Sector* sector; }; class Portal : public CS::Utility::FastRefCount<Portal> @@ -205,7 +212,7 @@ { } - bool InRange(csVector3& pos) + bool InRange(const csVector3& pos) { for(int i=0; i<num_vertices; i++) { @@ -218,7 +225,7 @@ return false; } - bool OutOfRange(csVector3& pos) + bool OutOfRange(const csVector3& pos) { for(int i=0; i<num_vertices; i++) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2008-12-23 07:52:32
|
Revision: 2749 http://planeshift.svn.sourceforge.net/planeshift/?rev=2749&view=rev Author: mgist Date: 2008-12-23 07:52:28 +0000 (Tue, 23 Dec 2008) Log Message: ----------- - Made the map precache thread safe and made it work in the background during login and char select/create. Modified Paths: -------------- trunk/src/client/charapp.cpp trunk/src/client/psengine.cpp trunk/src/client/psengine.h trunk/src/common/engine/loader.cpp trunk/src/common/engine/loader.h trunk/src/common/paws/pawsobjectview.cpp Modified: trunk/src/client/charapp.cpp =================================================================== --- trunk/src/client/charapp.cpp 2008-12-23 06:44:30 UTC (rev 2748) +++ trunk/src/client/charapp.cpp 2008-12-23 07:52:28 UTC (rev 2749) @@ -47,9 +47,6 @@ eyeColorSet = false; hairAttached = true; hairColorSet = false; - - state = NULL; - stateFactory = NULL; } psCharAppearance::~psCharAppearance() Modified: trunk/src/client/psengine.cpp =================================================================== --- trunk/src/client/psengine.cpp 2008-12-23 06:44:30 UTC (rev 2748) +++ trunk/src/client/psengine.cpp 2008-12-23 07:52:28 UTC (rev 2749) @@ -567,27 +567,6 @@ unloadLast = GetConfig()->GetBool("PlaneShift.Client.Loading.UnloadLast", true); - threadedLoading = !psengine->GetConfig()->GetBool("ThreadManager.AlwaysRunNow"); - - Loader* loader = new Loader(); - Loader::GetSingleton().Init(object_reg, preloadModels, gfxFeatures, 500); - - if(threadedLoading) - { - csString path; - csRef<iStringArray> maps = vfs->FindFiles("/planeshift/world/"); - for(size_t i=0; i<maps->GetSize(); i++) - { - vfs->PushDir(maps->Get(i)); - csRef<iDataBuffer> tmp = vfs->GetRealPath(maps->Get(i)); - path.AppendFmt("%s, ", tmp->GetData()); - Loader::GetSingleton().PrecacheData("world"); - vfs->PopDir(); - } - vfs->SetSyncDir("/planeshift/maps/"); - vfs->Mount("/planeshift/maps/", path); - } - if (!celclient->Initialize(object_reg, GetMsgHandler(), zonehandler)) { lasterror = "Couldn't init Cel Manager."; @@ -639,6 +618,26 @@ return 1; } + threadedLoading = !psengine->GetConfig()->GetBool("ThreadManager.AlwaysRunNow"); + + Loader* loader = new Loader(); + Loader::GetSingleton().Init(object_reg, preloadModels, gfxFeatures, 500); + + if(threadedLoading) + { + csString path; + csRef<iStringArray> maps = vfs->FindFiles("/planeshift/world/"); + for(size_t i=0; i<maps->GetSize(); i++) + { + csRef<iDataBuffer> tmp = vfs->GetRealPath(maps->Get(i)); + path.AppendFmt("%s, ", tmp->GetData()); + csString path(maps->Get(i)); + path.Append("/world"); + precaches.Push(Loader::GetSingleton().PrecacheData(path.GetData(), false)); + } + vfs->Mount("/planeshift/maps/", path); + } + okToLoadModels = true; return true; @@ -1241,6 +1240,23 @@ if (!charController->IsReady()) return; // Wait for character modes + // Make sure all the maps have been precached. + bool precached = true; + for(size_t i=0; i<precaches.GetSize(); i++) + { + precached &= precaches[i]->IsFinished(); + } + + if(precached) + { + precaches.Empty(); + vfs->SetSyncDir("/planeshift/maps/"); + } + else + { + return; + } + celclient->RequestServerWorld(); loadtimeout = csGetTicks () + cfgmgr->GetInt("PlaneShift.Client.User.Persisttimeout", 60) * 1000; Modified: trunk/src/client/psengine.h =================================================================== --- trunk/src/client/psengine.h 2008-12-23 06:44:30 UTC (rev 2748) +++ trunk/src/client/psengine.h 2008-12-23 07:52:28 UTC (rev 2749) @@ -422,6 +422,7 @@ bool okToLoadModels; ///< True if we can load models now. csStringArray modelnames; csHash<csString, csString> factfilenames; + csRefArray<iThreadReturn> precaches; public: bool GetFileNameByFact(csString factName, csString& fileName); Modified: trunk/src/common/engine/loader.cpp =================================================================== --- trunk/src/common/engine/loader.cpp 2008-12-23 06:44:30 UTC (rev 2748) +++ trunk/src/common/engine/loader.cpp 2008-12-23 07:52:28 UTC (rev 2749) @@ -58,7 +58,7 @@ } } -void Loader::PrecacheData(const char* path) +THREADED_CALLABLE_IMPL2(Loader, PrecacheData, const char* path, bool recursive) { if(vfs->Exists(path)) { @@ -66,6 +66,11 @@ csRef<iDocument> doc = docsys->CreateDocument(); csRef<iDataBuffer> data = vfs->ReadFile(path); + if(!recursive) + { + vfs->ChDir(csString(path).Truncate(csString(path).FindLast('/'))); + } + doc->Parse(data, true); csRef<iDocumentNode> root = doc->GetRoot()->GetNode("library"); @@ -83,7 +88,7 @@ while(nodeItr->HasNext()) { node = nodeItr->Next(); - PrecacheData(node->GetContentsValue()); + PrecacheData(node->GetContentsValue(), true); } node = root->GetNode("plugins"); @@ -113,7 +118,10 @@ { node = nodeItr->Next(); csRef<Texture> t = csPtr<Texture>(new Texture()); - textures.Push(t); + { + CS::Threading::MutexScopedLock lock(tLock); + textures.Push(t); + } t->name = node->GetAttributeValue("name"); t->data = node; } @@ -127,7 +135,10 @@ { node = nodeItr->Next(); csRef<Material> m = csPtr<Material>(new Material(node->GetAttributeValue("name"))); - materials.Push(m); + { + CS::Threading::MutexScopedLock lock(mLock); + materials.Push(m); + } if(node->GetNode("texture")) { @@ -136,6 +147,7 @@ sv.value = node->GetContentsValue(); m->shadervars.Push(sv); + CS::Threading::MutexScopedLock lock(tLock); for(size_t i=0; i<textures.GetSize(); i++) { if(textures[i]->name.Compare(node->GetContentsValue())) @@ -164,6 +176,7 @@ ShaderVar sv(node->GetAttributeValue("name"), csShaderVariable::TEXTURE); sv.value = node->GetContentsValue(); m->shadervars.Push(sv); + CS::Threading::MutexScopedLock lock(tLock); for(size_t i=0; i<textures.GetSize(); i++) { if(textures[i]->name.Compare(node->GetContentsValue())) @@ -194,6 +207,7 @@ csRef<iDocumentNode> node2 = nodeItr3->Next(); if(node2->GetNode("material")) { + CS::Threading::MutexScopedLock lock(mLock); for(size_t i=0; i<materials.GetSize(); i++) { if(materials[i]->name.Compare(node2->GetNode("material")->GetContentsValue())) @@ -207,11 +221,14 @@ if(node->GetNode("params")->GetNode("cells")) { node = node->GetNode("params")->GetNode("cells")->GetNode("celldefault")->GetNode("basematerial"); - for(size_t i=0; i<materials.GetSize(); i++) { - if(materials[i]->name.Compare(node->GetContentsValue())) + CS::Threading::MutexScopedLock lock(mLock); + for(size_t i=0; i<materials.GetSize(); i++) { - mf->materials.PushSmart(materials[i]); + if(materials[i]->name.Compare(node->GetContentsValue())) + { + mf->materials.PushSmart(materials[i]); + } } } node = node->GetParent()->GetParent(); @@ -227,6 +244,7 @@ while(nodeItr4->HasNext()) { csRef<iDocumentNode> node2 = nodeItr4->Next(); + CS::Threading::MutexScopedLock lock(mLock); for(size_t i=0; i<materials.GetSize(); i++) { if(materials[i]->name.Compare(node2->GetAttributeValue("material"))) @@ -239,6 +257,7 @@ } } + CS::Threading::MutexScopedLock lock(mfLock); meshfacts.Push(mf); } @@ -249,18 +268,22 @@ csRef<Sector> s; csString sectorName = node->GetAttributeValue("name"); - for(size_t i=0; i<sectors.GetSize(); i++) { - if(sectors[i]->name.Compare(sectorName)) + CS::Threading::MutexScopedLock lock(sLock); + for(size_t i=0; i<sectors.GetSize(); i++) { - s = sectors[i]; - break; + if(sectors[i]->name.Compare(sectorName)) + { + s = sectors[i]; + break; + } } } if(!s.IsValid()) { s = csPtr<Sector>(new Sector(sectorName)); + CS::Threading::MutexScopedLock lock(sLock); sectors.Push(s); } @@ -302,6 +325,7 @@ csRef<iDocumentNode> node3 = nodeItr3->Next(); if(node3->GetNode("material")) { + CS::Threading::MutexScopedLock lock(mLock); for(size_t i=0; i<materials.GetSize(); i++) { if(materials[i]->name.Compare(node3->GetNode("material")->GetContentsValue())) @@ -317,6 +341,7 @@ node3 = nodeItr4->Next(); if(csString("texture").Compare(node3->GetAttributeValue("type"))) { + CS::Threading::MutexScopedLock lock(tLock); for(size_t i=0; i<textures.GetSize(); i++) { if(textures[i]->name.Compare(node3->GetContentsValue())) @@ -329,11 +354,14 @@ } node2 = node2->GetNode("params")->GetNode("factory"); - for(size_t i=0; i<meshfacts.GetSize(); i++) { - if(meshfacts[i]->name.Compare(node2->GetContentsValue())) + CS::Threading::MutexScopedLock lock(mfLock); + for(size_t i=0; i<meshfacts.GetSize(); i++) { - m->meshfacts.PushSmart(meshfacts[i]); + if(meshfacts[i]->name.Compare(node2->GetContentsValue())) + { + m->meshfacts.PushSmart(meshfacts[i]); + } } } node2 = node2->GetParent(); @@ -341,6 +369,7 @@ if(node2->GetNode("material")) { node2 = node2->GetNode("material"); + CS::Threading::MutexScopedLock lock(mLock); for(size_t i=0; i<materials.GetSize(); i++) { if(materials[i]->name.Compare(node2->GetContentsValue())) @@ -358,6 +387,7 @@ while(nodeItr3->HasNext()) { csRef<iDocumentNode> node3 = nodeItr3->Next(); + CS::Threading::MutexScopedLock lock(mLock); for(size_t i=0; i<materials.GetSize(); i++) { if(materials[i]->name.Compare(node3->GetContentsValue())) @@ -382,6 +412,7 @@ csRef<iDocumentNode> node3 = nodeItr4->Next(); if(csString("texture").Compare(node3->GetAttributeValue("type"))) { + CS::Threading::MutexScopedLock lock(tLock); for(size_t i=0; i<textures.GetSize(); i++) { if(textures[i]->name.Compare(node3->GetContentsValue())) @@ -428,18 +459,22 @@ } csString targetSector = node2->GetNode("sector")->GetContentsValue(); - for(size_t i=0; i<sectors.GetSize(); i++) { - if(targetSector == sectors[i]->name) + CS::Threading::MutexScopedLock lock(sLock); + for(size_t i=0; i<sectors.GetSize(); i++) { - p->targetSector = sectors[i]; - break; + if(targetSector == sectors[i]->name) + { + p->targetSector = sectors[i]; + break; + } } } if(!p->targetSector.IsValid()) { p->targetSector = csPtr<Sector>(new Sector(targetSector)); + CS::Threading::MutexScopedLock lock(sLock); sectors.Push(p->targetSector); } @@ -513,6 +548,8 @@ } } } + + return true; } void Loader::UpdatePosition(const csVector3& pos, const char* sectorName, bool force) Modified: trunk/src/common/engine/loader.h =================================================================== --- trunk/src/common/engine/loader.h 2008-12-23 06:44:30 UTC (rev 2748) +++ trunk/src/common/engine/loader.h 2008-12-23 07:52:28 UTC (rev 2749) @@ -22,6 +22,7 @@ #include <csgfx/shadervar.h> #include <csutil/scf_implementation.h> +#include <csutil/threadmanager.h> #include <iengine/engine.h> #include <iengine/material.h> @@ -37,7 +38,7 @@ struct iCollideSystem; struct iObjectRegistry; -class Loader : public Singleton<Loader> +class Loader : public Singleton<Loader>, public ThreadedCallable<Loader> { public: void Init(iObjectRegistry* _object_reg, bool _keepModels, uint gfxFeatures, float loadRange); @@ -46,7 +47,7 @@ iTextureWrapper* LoadTexture (const char* name, const char* filename, const char* className = 0); - void PrecacheData(const char* path); + THREADED_CALLABLE_DECL2(Loader, PrecacheData, csThreadReturn, const char*, path, bool, recursive, THREADEDL, false, false); void UpdatePosition(const csVector3& pos, const char* sectorName, bool force); bool PreloadTextures(); @@ -56,6 +57,8 @@ size_t GetLoadingCount() { return loadingMeshes.GetSize(); } + iObjectRegistry* GetObjectRegistry() const { return object_reg; } + private: class Texture; class Material; @@ -98,6 +101,11 @@ csRefArray<MeshFact> meshfacts; csRefArray<Sector> sectors; + CS::Threading::Mutex tLock; + CS::Threading::Mutex mLock; + CS::Threading::Mutex mfLock; + CS::Threading::Mutex sLock; + struct Shader { csString type; Modified: trunk/src/common/paws/pawsobjectview.cpp =================================================================== --- trunk/src/common/paws/pawsobjectview.cpp 2008-12-23 06:44:30 UTC (rev 2748) +++ trunk/src/common/paws/pawsobjectview.cpp 2008-12-23 07:52:28 UTC (rev 2749) @@ -157,7 +157,6 @@ engine->SetCacheManager(NULL); csRef<iThreadReturn> itr = loader->LoadMap(worldNode, CS_LOADER_KEEP_WORLD, col); itr->Wait(); - VFS->SetSyncDir("/planeshift/maps/"); if (!itr->WasSuccessful()) return false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2008-12-23 19:11:17
|
Revision: 2750 http://planeshift.svn.sourceforge.net/planeshift/?rev=2750&view=rev Author: mgist Date: 2008-12-23 19:11:12 +0000 (Tue, 23 Dec 2008) Log Message: ----------- - Warning fixes. Modified Paths: -------------- trunk/src/client/pscelclient.cpp trunk/src/client/psengine.cpp trunk/src/common/effects/pseffectobjlabel.cpp trunk/src/common/effects/pseffectobjquad.cpp trunk/src/common/effects/pseffectobjspire.cpp trunk/src/common/effects/pseffectobjstar.cpp trunk/src/common/effects/pseffectobjtrail.cpp trunk/src/common/engine/loader.cpp trunk/src/common/engine/loader.h trunk/src/common/net/messages.cpp trunk/src/common/paws/pawsbutton.cpp trunk/src/common/paws/pawswidget.cpp trunk/src/common/util/consoleout.cpp Modified: trunk/src/client/pscelclient.cpp =================================================================== --- trunk/src/client/pscelclient.cpp 2008-12-23 07:52:28 UTC (rev 2749) +++ trunk/src/client/pscelclient.cpp 2008-12-23 19:11:12 UTC (rev 2750) @@ -786,7 +786,6 @@ for(size_t i =0; i < entities.GetSize();i++) { entities[i]->Update(); - GEMClientActor* actor = dynamic_cast<GEMClientActor*>(entities[i]); } // Update loader. Modified: trunk/src/client/psengine.cpp =================================================================== --- trunk/src/client/psengine.cpp 2008-12-23 07:52:28 UTC (rev 2749) +++ trunk/src/client/psengine.cpp 2008-12-23 19:11:12 UTC (rev 2750) @@ -620,7 +620,7 @@ threadedLoading = !psengine->GetConfig()->GetBool("ThreadManager.AlwaysRunNow"); - Loader* loader = new Loader(); + loader = new Loader(); Loader::GetSingleton().Init(object_reg, preloadModels, gfxFeatures, 500); if(threadedLoading) @@ -846,7 +846,6 @@ if(!delayedLoaders.IsEmpty()) { - csTicks c = csGetTicks(); csWeakRef<DelayedLoader> dl = delayedLoaders.Get(0); if(dl.IsValid()) { @@ -1928,7 +1927,7 @@ void psEngine::FatalError(const char* msg) { loadstate = LS_ERROR; - Bug1(msg); + Bug2("%s\n", msg); pawsQuitInfoBox* quitinfo = (pawsQuitInfoBox*)(paws->FindWidget("QuitInfoWindow")); if (quitinfo) Modified: trunk/src/common/effects/pseffectobjlabel.cpp =================================================================== --- trunk/src/common/effects/pseffectobjlabel.cpp 2008-12-23 07:52:28 UTC (rev 2749) +++ trunk/src/common/effects/pseffectobjlabel.cpp 2008-12-23 19:11:12 UTC (rev 2750) @@ -265,7 +265,6 @@ mesh->GetMeshObject()->GetObjectModel()->SetTriangleData(viscull_id, 0); genState = scfQueryInterface<iGeneralMeshState> (mesh->GetMeshObject()); - genState->SetLighting(false); // obj specific Modified: trunk/src/common/effects/pseffectobjquad.cpp =================================================================== --- trunk/src/common/effects/pseffectobjquad.cpp 2008-12-23 07:52:28 UTC (rev 2749) +++ trunk/src/common/effects/pseffectobjquad.cpp 2008-12-23 19:11:12 UTC (rev 2750) @@ -118,7 +118,6 @@ // obj specific genState = scfQueryInterface<iGeneralMeshState> (mesh->GetMeshObject()); - genState->SetLighting(false); if (mixmode != CS_FX_ALPHA) mesh->GetMeshObject()->SetMixMode(mixmode); // to check Modified: trunk/src/common/effects/pseffectobjspire.cpp =================================================================== --- trunk/src/common/effects/pseffectobjspire.cpp 2008-12-23 07:52:28 UTC (rev 2749) +++ trunk/src/common/effects/pseffectobjspire.cpp 2008-12-23 19:11:12 UTC (rev 2750) @@ -133,7 +133,6 @@ // obj specific genState = scfQueryInterface<iGeneralMeshState> (mesh->GetMeshObject()); - genState->SetLighting(false); mesh->GetMeshObject()->SetColor(csColor(1,1,1)); // to check //genState->SetColor(csColor(1,1,1)); was not working with latest CS Modified: trunk/src/common/effects/pseffectobjstar.cpp =================================================================== --- trunk/src/common/effects/pseffectobjstar.cpp 2008-12-23 07:52:28 UTC (rev 2749) +++ trunk/src/common/effects/pseffectobjstar.cpp 2008-12-23 19:11:12 UTC (rev 2750) @@ -122,7 +122,6 @@ // obj specific genState = scfQueryInterface<iGeneralMeshState> (mesh->GetMeshObject()); - genState->SetLighting(false); mesh->GetMeshObject()->SetColor(csColor(1,1,1)); // to check //genState->SetColor(csColor(1,1,1)); was not working with latest CS Modified: trunk/src/common/effects/pseffectobjtrail.cpp =================================================================== --- trunk/src/common/effects/pseffectobjtrail.cpp 2008-12-23 07:52:28 UTC (rev 2749) +++ trunk/src/common/effects/pseffectobjtrail.cpp 2008-12-23 19:11:12 UTC (rev 2750) @@ -144,7 +144,6 @@ // obj specific genState = scfQueryInterface<iGeneralMeshState> (mesh->GetMeshObject()); - genState->SetLighting(false); mesh->GetMeshObject()->SetColor(csColor(1,1,1)); // to check //genState->SetColor(csColor(1,1,1)); was not working with latest CS Modified: trunk/src/common/engine/loader.cpp =================================================================== --- trunk/src/common/engine/loader.cpp 2008-12-23 07:52:28 UTC (rev 2749) +++ trunk/src/common/engine/loader.cpp 2008-12-23 19:11:12 UTC (rev 2750) @@ -854,7 +854,7 @@ csRefArray<csShaderVariable> shadervars; csRef<iMaterial> mat (engine->CreateBaseMaterial(0)); - iMaterialWrapper* mw = engine->GetMaterialList()->NewMaterial(mat, material->name); + engine->GetMaterialList()->NewMaterial(mat, material->name); for(size_t i=0; i<material->shaders.GetSize(); i++) { Modified: trunk/src/common/engine/loader.h =================================================================== --- trunk/src/common/engine/loader.h 2008-12-23 07:52:28 UTC (rev 2749) +++ trunk/src/common/engine/loader.h 2008-12-23 19:11:12 UTC (rev 2750) @@ -138,9 +138,9 @@ { } + csString name; bool loaded; csRef<iThreadReturn> status; - csString name; csRef<iDocumentNode> data; }; @@ -152,8 +152,8 @@ { } + csString name; bool loaded; - csString name; csArray<Shader> shaders; csArray<ShaderVar> shadervars; csRefArray<Texture> textures; @@ -162,13 +162,13 @@ class MeshFact : public CS::Utility::FastRefCount<MeshFact> { public: - MeshFact(const char* name, iDocumentNode* data) : name(name), data(data), loaded(false) + MeshFact(const char* name, iDocumentNode* data) : name(name), loaded(false), data(data) { } + csString name; bool loaded; csRef<iThreadReturn> status; - csString name; csRef<iDocumentNode> data; csRefArray<Material> materials; }; @@ -181,8 +181,8 @@ ambient = csColor(0.0f); } + csString name; bool isLoading; - csString name; csString culler; csColor ambient; size_t objectCount; Modified: trunk/src/common/net/messages.cpp =================================================================== --- trunk/src/common/net/messages.cpp 2008-12-23 07:52:28 UTC (rev 2749) +++ trunk/src/common/net/messages.cpp 2008-12-23 19:11:12 UTC (rev 2750) @@ -3450,7 +3450,7 @@ { csString msgtext; - msgtext.AppendFmt("Event Type: %d Attack Anim: %lu Defense Anim: %lu Attacker: %d Target: %d Location: %d", + msgtext.AppendFmt("Event Type: %d Attack Anim: %d Defense Anim: %d Attacker: %d Target: %d Location: %d", event_type, attack_anim, defense_anim, attacker_id.Unbox(), target_id.Unbox(), target_location); if (event_type == COMBAT_DAMAGE) { Modified: trunk/src/common/paws/pawsbutton.cpp =================================================================== --- trunk/src/common/paws/pawsbutton.cpp 2008-12-23 07:52:28 UTC (rev 2749) +++ trunk/src/common/paws/pawsbutton.cpp 2008-12-23 19:11:12 UTC (rev 2750) @@ -315,12 +315,20 @@ bool pawsButton::OnMouseDown( int button, int modifiers, int x, int y ) { if ( !enabled ) + { return true; + } else if ( button == csmbWheelUp || button == csmbWheelDown ) + { if ( parent ) + { return parent->OnMouseDown(button, modifiers, x, y); - else + } + else + { return false; + } + } // plays a sound PawsManager::GetSingleton().PlaySound(sound_click); Modified: trunk/src/common/paws/pawswidget.cpp =================================================================== --- trunk/src/common/paws/pawswidget.cpp 2008-12-23 07:52:28 UTC (rev 2749) +++ trunk/src/common/paws/pawswidget.cpp 2008-12-23 19:11:12 UTC (rev 2750) @@ -2465,7 +2465,7 @@ const char *error = doc->Parse( xmlstr ); if (error) { - Error1(error); + Error2("%s\n", error); return false; } csRef<iDocumentNode> root = doc->GetRoot(); Modified: trunk/src/common/util/consoleout.cpp =================================================================== --- trunk/src/common/util/consoleout.cpp 2008-12-23 07:52:28 UTC (rev 2749) +++ trunk/src/common/util/consoleout.cpp 2008-12-23 19:11:12 UTC (rev 2750) @@ -173,7 +173,7 @@ printf("\n"); promptDisplayed = false; } - printf(output.GetDataSafe()); + printf("%s", output.GetDataSafe()); fflush(stdout); } } @@ -182,7 +182,7 @@ // Check for output file if (outputfile && con <= maxoutput_file) { - fprintf(outputfile, output.GetDataSafe()); + fprintf(outputfile, "%s", output.GetDataSafe()); } // Check for error log if (con == CON_ERROR || @@ -195,7 +195,7 @@ if(errorLog) { - fprintf(errorLog, output.GetDataSafe()); + fprintf(errorLog, "%s", output.GetDataSafe()); fflush(errorLog); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2008-12-23 22:58:13
|
Revision: 2758 http://planeshift.svn.sourceforge.net/planeshift/?rev=2758&view=rev Author: mgist Date: 2008-12-23 21:35:57 +0000 (Tue, 23 Dec 2008) Log Message: ----------- - Added some more portal functionality. Modified Paths: -------------- trunk/src/client/psengine.cpp trunk/src/common/engine/loader.cpp trunk/src/common/engine/loader.h Modified: trunk/src/client/psengine.cpp =================================================================== --- trunk/src/client/psengine.cpp 2008-12-23 21:14:08 UTC (rev 2757) +++ trunk/src/client/psengine.cpp 2008-12-23 21:35:57 UTC (rev 2758) @@ -62,6 +62,7 @@ ////////////////////////////////////////////////////////////////////////////// // CS files +#include <imap/services.h> #include <iutil/cfgmgr.h> #include <iutil/event.h> #include <iutil/eventq.h> Modified: trunk/src/common/engine/loader.cpp =================================================================== --- trunk/src/common/engine/loader.cpp 2008-12-23 21:14:08 UTC (rev 2757) +++ trunk/src/common/engine/loader.cpp 2008-12-23 21:35:57 UTC (rev 2758) @@ -23,9 +23,11 @@ #include <csutil/scanstr.h> #include <iengine/movable.h> #include <iengine/portal.h> +#include <imap/services.h> #include <imesh/object.h> #include <iutil/stringarray.h> #include <iutil/object.h> +#include <iutil/plugin.h> #include <ivaria/collider.h> #include <ivideo/material.h> @@ -47,7 +49,9 @@ strings = csQueryRegistryTagInterface<iStringSet>(object_reg, "crystalspace.shared.stringset"); cdsys = csQueryRegistry<iCollideSystem> (object_reg); - csRef<iGraphics3D> g3d = csQueryRegistry<iGraphics3D> (object_reg); + syntaxService = csQueryRegistryOrLoad<iSyntaxService>(object_reg, "crystalspace.syntax.loader.service.text"); + + csRef<iGraphics3D> g3d = csQueryRegistry<iGraphics3D>(object_reg); txtmgr = g3d->GetTextureManager(); engine->SetClearZBuf(true); @@ -438,24 +442,41 @@ csRef<iDocumentNode> node2 = nodeItr3->Next(); csRef<Portal> p = csPtr<Portal>(new Portal(node2->GetAttributeValue("name"))); + if(node2->GetNode("matrix")) + { + p->warp = true; + syntaxService->ParseMatrix(node2->GetNode("matrix"), p->matrix); + } + + if(node2->GetNode("wv")) + { + p->warp = true; + syntaxService->ParseVector(node2->GetNode("wv"), p->wv); + } + if(node2->GetNode("ww")) { - node2 = node2->GetNode("ww"); - p->ww = csVector3(node2->GetAttributeValueAsFloat("x"), - node2->GetAttributeValueAsFloat("y"), node2->GetAttributeValueAsFloat("z")); - node2 = node2->GetParent(); + p->warp = true; + p->ww_given = true; + syntaxService->ParseVector(node2->GetNode("ww"), p->ww); } + if(node2->GetNode("clip")) + { + p->clip = true; + } + + if(node2->GetNode("zfill")) + { + p->zfill = true; + } + csRef<iDocumentNodeIterator> nodeItr3 = node2->GetNodes("v"); while(nodeItr3->HasNext()) { - node2 = nodeItr3->Next(); csVector3 vec; - vec.x = node2->GetAttributeValueAsFloat("x"); - vec.y = node2->GetAttributeValueAsFloat("y"); - vec.z = node2->GetAttributeValueAsFloat("z"); + syntaxService->ParseVector(nodeItr3->Next(), vec); p->poly.AddVertex(vec); - node2 = node2->GetParent(); } csString targetSector = node2->GetNode("sector")->GetContentsValue(); @@ -530,18 +551,10 @@ l->type = CS_LIGHT_POINTLIGHT; - node = node->GetNode("center"); - l->pos = csVector3(node->GetAttributeValueAsFloat("x"), - node->GetAttributeValueAsFloat("y"), node->GetAttributeValueAsFloat("z")); - node = node->GetParent(); - + syntaxService->ParseVector(node->GetNode("center"), l->pos); l->radius = node->GetNode("radius")->GetContentsValueAsFloat(); + syntaxService->ParseColor(node->GetNode("color"), l->colour); - node = node->GetNode("color"); - l->colour = csColor(node->GetAttributeValueAsFloat("red"), - node->GetAttributeValueAsFloat("green"), node->GetAttributeValueAsFloat("blue")); - node = node->GetParent(); - s->lights.Push(l); node = node->GetParent(); } @@ -722,7 +735,28 @@ sector->portals[i]->mObject = engine->CreatePortal(sector->portals[i]->name, sector->object, csVector3(0), sector->portals[i]->targetSector->object, sector->portals[i]->poly.GetVertices(), - sector->portals[i]->poly.GetVertexCount(), sector->portals[i]->pObject); + (int)sector->portals[i]->poly.GetVertexCount(), sector->portals[i]->pObject); + + if(sector->portals[i]->warp) + { + if(!sector->portals[i]->ww_given) + { + sector->portals[i]->ww = sector->portals[i]->wv; + } + + sector->portals[i]->pObject->SetWarp(sector->portals[i]->matrix, sector->portals[i]->wv, sector->portals[i]->ww); + } + + if(sector->portals[i]->clip) + { + sector->portals[i]->pObject->GetFlags().SetBool(CS_PORTAL_CLIPDEST, true); + } + + if(sector->portals[i]->zfill) + { + sector->portals[i]->pObject->GetFlags().SetBool(CS_PORTAL_ZFILL, true); + } + sector->activePortals.Push(sector->portals[i]); ++sector->objectCount; } Modified: trunk/src/common/engine/loader.h =================================================================== --- trunk/src/common/engine/loader.h 2008-12-23 21:14:08 UTC (rev 2757) +++ trunk/src/common/engine/loader.h 2008-12-23 21:35:57 UTC (rev 2758) @@ -38,6 +38,7 @@ struct iCollideSystem; struct iObjectRegistry; +struct iSyntaxService; class Loader : public Singleton<Loader>, public ThreadedCallable<Loader> { @@ -90,6 +91,7 @@ csRef<iShaderVarStringSet> svstrings; csRef<iStringSet> strings; csRef<iCollideSystem> cdsys; + csRef<iSyntaxService> syntaxService; uint gfxFeatures; csRef<Sector> lastSector; @@ -217,7 +219,7 @@ class Portal : public CS::Utility::FastRefCount<Portal> { public: - Portal(const char* name) : name(name) + Portal(const char* name) : name(name), clip(false), zfill(false), warp(false), ww_given(false) { } @@ -248,7 +250,13 @@ } csString name; + csMatrix3 matrix; + csVector3 wv; + bool ww_given; csVector3 ww; + bool clip; + bool zfill; + bool warp; csPoly3D poly; csRef<Sector> targetSector; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wel...@us...> - 2008-12-24 09:34:08
|
Revision: 2766 http://planeshift.svn.sourceforge.net/planeshift/?rev=2766&view=rev Author: weltall2 Date: 2008-12-24 09:34:03 +0000 (Wed, 24 Dec 2008) Log Message: ----------- trimmed spaces/converted tabs to spaces Modified Paths: -------------- trunk/src/client/gui/pawsgmgui.cpp trunk/src/server/gem.cpp Modified: trunk/src/client/gui/pawsgmgui.cpp =================================================================== --- trunk/src/client/gui/pawsgmgui.cpp 2008-12-24 09:32:59 UTC (rev 2765) +++ trunk/src/client/gui/pawsgmgui.cpp 2008-12-24 09:34:03 UTC (rev 2766) @@ -109,7 +109,7 @@ playerList->SetSortingFunc(i, textBoxSortFunc); } playerList->SetSortedColumn(0); - + playerCount = (pawsTextBox*)FindWidget("PlayerCount"); if (!playerCount) return false; @@ -125,7 +125,7 @@ SetSecurity(); QueryServer(); - + currentTab = 0; // get a handle on the widgets in our Attributes tab @@ -297,7 +297,7 @@ case 1230: // kick pawsStringPromptWindow::Create( "Please enter a reason","", - false,250,20,this,"Reason", 0 ); + false,250,20,this,"Reason", 0 ); break; case 1231: // mute cmd.Format("/mute %s",GetSelectedName()); @@ -331,14 +331,14 @@ cmd.Format("/changename %s force %s %s",GetSelectedName(),first.GetData(),last.GetData()); updateAfter = true; - + break; } case 1236: // Ban player { pawsStringPromptWindow::Create( "Please enter a reason","", - false,250,20,this,"Reason", 1); + false,250,20,this,"Reason", 1); break; } ///////////////////////////////////////// @@ -449,7 +449,7 @@ return true; pawsTextBox* box = (pawsTextBox*)row->GetColumn(0); - + csString id = box->GetText(); // Loop through all Locations @@ -498,7 +498,7 @@ return true; pawsTextBox* box = (pawsTextBox*)row->GetColumn(0); - + csString id = box->GetText(); psengine->GetActionHandler()->DeleteAction( id ); @@ -674,12 +674,12 @@ void pawsGmGUIWindow::QueryServer() { if (psengine->IsGameLoaded()) - { + { if (psengine->GetCelClient()->GetMainPlayer()->GetType() < 21) { this->Hide(); return; - } + } if (IsVisible()) { @@ -691,7 +691,7 @@ QueryActionLocations(); } - } + } } void pawsGmGUIWindow::QueryActionLocations() @@ -737,7 +737,7 @@ void pawsGmGUIWindow::FillPlayerList(psGMGuiMessage& msg) { csArray<int> playerOrder; - + // Clear the list from old data int sortedCol = playerList->GetSortedColumn(); csString selectedPlayer; @@ -751,7 +751,7 @@ // Make stuff easier //int playerNum = playerOrder[i]; psGMGuiMessage::PlayerInfo playerInfo = msg.players.Get(i); - + playerList->NewRow(i); pawsTextBox* nameBox = (pawsTextBox*)((pawsListBoxRow*)playerList->GetRow(i))->GetColumn(0); pawsTextBox* lastNameBox = (pawsTextBox*)((pawsListBoxRow*)playerList->GetRow(i))->GetColumn(1); @@ -773,7 +773,7 @@ // Set the name csString name = playerInfo.name; nameBox->SetText(name); - + // Select if needed if (name == selectedPlayer) playerList->Select(playerList->GetRow(i), true); @@ -900,9 +900,9 @@ if ( node->GetNode( "x" ) ) posx = node->GetNode( "x" )->GetContentsValueAsFloat(); if ( node->GetNode( "y" ) ) posy = node->GetNode( "y" )->GetContentsValueAsFloat(); if ( node->GetNode( "z" ) ) posz = node->GetNode( "z" )->GetContentsValueAsFloat(); - + posStr.Format( posFormat, posx, posy, posz ); - + posBox->SetText( posStr.GetData() ); } @@ -923,7 +923,7 @@ printf("Couldn't find widget %s!\n",name); return; } - + widget->Hide(); } @@ -935,7 +935,7 @@ printf("Couldn't find widget %s!\n",name); return; } - + widget->Show(); } @@ -957,7 +957,7 @@ return PSCHARACTER_GENDER_NONE; pawsTextBox* box = (pawsTextBox*)row->GetColumn(1); - + csString gender = box->GetText(); if (gender == "M") return PSCHARACTER_GENDER_MALE; @@ -965,7 +965,7 @@ return PSCHARACTER_GENDER_FEMALE; else return PSCHARACTER_GENDER_NONE; - + } const char* pawsGmGUIWindow::GetSelectedSector() @@ -1015,10 +1015,10 @@ int place = (int)text.FindFirst(' '); csString firstName,lastName; - + // TODO Does this make sense? Split the name to concat it? if (place == -1) - { + { firstName = text; } else Modified: trunk/src/server/gem.cpp =================================================================== --- trunk/src/server/gem.cpp 2008-12-24 09:32:59 UTC (rev 2765) +++ trunk/src/server/gem.cpp 2008-12-24 09:34:03 UTC (rev 2766) @@ -3535,44 +3535,44 @@ void gemNPC::ShowPopupMenu(Client *client) { NpcResponse *resp = NULL; - NpcDialogMenu menu; - + NpcDialogMenu menu; + csArray<QuestAssignment*>& quests = client->GetCharacterData()->GetAssignedQuests(); - // Merge current spot in active quests first - for (size_t i=0; i < quests.GetSize(); i++) - { - psQuest *q = quests[i]->GetQuest(); + // Merge current spot in active quests first + for (size_t i=0; i < quests.GetSize(); i++) + { + psQuest *q = quests[i]->GetQuest(); // If the quest is completed or the last response was not from this NPC, then skip - if (quests[i]->last_response_from_npc_pid != pid || quests[i]->status == 'C') - { - printf("Skipping completed or irrelevant quest: %s\n", q->GetName() ); - continue; - } - printf("Checking quest %d: %s. ", i, q->GetName() ); - int last_response = quests[i]->last_response; - printf("Got last response %d\n", last_response); - - if (last_response != -1) // within a quest step - { - resp = dict->FindResponse(last_response); - menu.Add(resp->menu); - } - else - { - printf("Got last_response==-1 for quest %d.\n",i); - } - } + if (quests[i]->last_response_from_npc_pid != pid || quests[i]->status == 'C') + { + printf("Skipping completed or irrelevant quest: %s\n", q->GetName() ); + continue; + } + printf("Checking quest %d: %s. ", i, q->GetName() ); + int last_response = quests[i]->last_response; + printf("Got last response %d\n", last_response); - // Also offer default choices in case a new quest should be started - NpcDialogMenu *npcmenu = dict->FindMenu( name ); - if (npcmenu) - menu.Add(npcmenu); + if (last_response != -1) // within a quest step + { + resp = dict->FindResponse(last_response); + menu.Add(resp->menu); + } + else + { + printf("Got last_response==-1 for quest %d.\n",i); + } + } - if (menu.triggers.GetSize()) - menu.ShowMenu(client); - else - psserver->SendSystemError(client->GetClientNum(), "This NPC has nothing to say to you."); + // Also offer default choices in case a new quest should be started + NpcDialogMenu *npcmenu = dict->FindMenu( name ); + if (npcmenu) + menu.Add(npcmenu); + + if (menu.triggers.GetSize()) + menu.ShowMenu(client); + else + psserver->SendSystemError(client->GetClientNum(), "This NPC has nothing to say to you."); } csString gemNPC::GetDefaultBehavior(const csString & dfltBehaviors) @@ -4005,11 +4005,11 @@ if (client->GetSecurityLevel() >= GM_DEVELOPER) return true; - /* \note - * The check if the item is NPCOwned or NoPickup only makes + /* \note + * The check if the item is NPCOwned or NoPickup only makes * sense if it is not possible to have NPCOwned items in a not * NPCOwned container, or NoPickup items in a PickUpable container - */ + */ //not allowed to take npcowned or nopickup items in a container if (item->GetIsNpcOwned() || item->GetIsNoPickup()) return false; @@ -4036,9 +4036,9 @@ gemActor* guardingActor = GEMSupervisor::GetSingleton().FindPlayerEntity(guard); if ((!guard.IsValid() || guard == client->GetCharacterData()->GetPID() || !guardingActor) || (guardingActor->RangeTo(this) > 5)) - { + { return true; - } + } return false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2008-12-24 19:05:31
|
Revision: 2769 http://planeshift.svn.sourceforge.net/planeshift/?rev=2769&view=rev Author: mgist Date: 2008-12-24 19:05:27 +0000 (Wed, 24 Dec 2008) Log Message: ----------- - Fixed pawsobjectview and related code. - Changed the char select unload to occur after gui load, so that podium isn't unloaded and reloaded. Modified Paths: -------------- trunk/src/client/authentclient.cpp trunk/src/client/charapp.cpp trunk/src/client/gui/inventorywindow.cpp trunk/src/client/gui/pawsskillwindow.cpp trunk/src/client/psclientchar.cpp trunk/src/client/psengine.cpp trunk/src/client/zonehandler.cpp trunk/src/common/paws/pawsobjectview.cpp trunk/src/common/paws/pawsobjectview.h Modified: trunk/src/client/authentclient.cpp =================================================================== --- trunk/src/client/authentclient.cpp 2008-12-24 16:05:32 UTC (rev 2768) +++ trunk/src/client/authentclient.cpp 2008-12-24 19:05:27 UTC (rev 2769) @@ -84,8 +84,8 @@ // This means that the character selected was ok and we should start // loading the game. case MSGTYPE_AUTHCHARACTERAPPROVED: - { - delete PawsManager::GetSingleton().FindWidget("CharPickerWindow"); + { + PawsManager::GetSingleton().FindWidget("CharPickerWindow")->Hide(); psengine->StartLoad(); break; } Modified: trunk/src/client/charapp.cpp =================================================================== --- trunk/src/client/charapp.cpp 2008-12-24 16:05:32 UTC (rev 2768) +++ trunk/src/client/charapp.cpp 2008-12-24 19:05:27 UTC (rev 2769) @@ -382,13 +382,10 @@ ChangeMaterial( ParseStrings(part,subMesh),texture, texture); } } - else + else if ( part.Length() ) { - if ( part.Length() ) - { - ChangeMaterial(part, texture, texture); - } - } + ChangeMaterial(part, texture, texture); + } } Modified: trunk/src/client/gui/inventorywindow.cpp =================================================================== --- trunk/src/client/gui/inventorywindow.cpp 2008-12-24 16:05:32 UTC (rev 2768) +++ trunk/src/client/gui/inventorywindow.cpp 2008-12-24 19:05:27 UTC (rev 2769) @@ -213,48 +213,41 @@ bool pawsInventoryWindow::SetupDoll() { pawsObjectView* widget = dynamic_cast<pawsObjectView*>(FindWidget("InventoryDoll")); - if (widget){ - GEMClientActor* actor = psengine->GetCelClient()->GetMainPlayer(); - if (!widget || !actor) - return false; - - csRef<iMeshWrapper> mesh = actor->GetMesh(); - if (!mesh) + if (widget) { - return false; - } + GEMClientActor* actor = psengine->GetCelClient()->GetMainPlayer(); + if (!widget || !actor) + return false; - // Set the doll view - widget->View( mesh ); + csRef<iMeshWrapper> mesh = actor->GetMesh(); + if (!mesh) + { + return false; + } - // Register this doll for updates - widget->SetID(actor->GetEID().Unbox()); + // Set the doll view + widget->View( mesh ); - csRef<iSpriteCal3DState> spstate = scfQueryInterface<iSpriteCal3DState> (widget->GetObject()->GetMeshObject()); - if (spstate) - { - // Setup cal3d to select random 0 velocity anims - spstate->SetVelocity(0.0,&psengine->GetRandomGen()); - } + // Set the charApp. + widget->SetCharApp(charApp); - charApp->Clone(actor->charApp); - charApp->SetMesh(widget->GetObject()); + // Register this doll for updates + widget->SetID(actor->GetEID().Unbox()); - //printf("Inventory Applying Traits: %s\n", actor->traits.GetData()); - //printf("Inventory Applying Equipment: %s\n", actor->equipment.GetData()); + csRef<iSpriteCal3DState> spstate = scfQueryInterface<iSpriteCal3DState> (widget->GetObject()->GetMeshObject()); + if (spstate) + { + // Setup cal3d to select random 0 velocity anims + spstate->SetVelocity(0.0,&psengine->GetRandomGen()); + } + charApp->Clone(actor->charApp); + charApp->SetMesh(widget->GetObject()); - charApp->ApplyTraits(actor->traits); - charApp->ApplyEquipment(actor->equipment); - - // Build doll appearance and equipment - //bool a = psengine->BuildAppearance( widget->GetObject(), actor->traits ); - //bool e = psengine->BuildEquipment( widget->GetObject(), actor->equipment, actor->traitList ); - - + charApp->ApplyTraits(actor->traits); + charApp->ApplyEquipment(actor->equipment); } return true; - //return (a && e); } bool pawsInventoryWindow::OnMouseDown( int button, int keyModifier, int x, int y ) Modified: trunk/src/client/gui/pawsskillwindow.cpp =================================================================== --- trunk/src/client/gui/pawsskillwindow.cpp 2008-12-24 16:05:32 UTC (rev 2768) +++ trunk/src/client/gui/pawsskillwindow.cpp 2008-12-24 19:05:27 UTC (rev 2769) @@ -175,6 +175,9 @@ // Set the doll view widget->View( mesh ); + // Set the charApp. + widget->SetCharApp(charApp); + // Register this doll for updates widget->SetID(actor->GetEID().Unbox()); Modified: trunk/src/client/psclientchar.cpp =================================================================== --- trunk/src/client/psclientchar.cpp 2008-12-24 16:05:32 UTC (rev 2768) +++ trunk/src/client/psclientchar.cpp 2008-12-24 19:05:27 UTC (rev 2769) @@ -428,8 +428,6 @@ if ( equip.type == psEquipmentMessage::EQUIP ) { // Update the actor - //Equip(object->pcmesh->GetMesh(), &equip, slotname, object->traitList); - object->charApp->Equip(slotname,equip.mesh,equip.part,equip.partMesh,equip.texture); // Update any doll views registered for changes @@ -450,10 +448,10 @@ Error2("Cannot update registered doll view with ID %d because it has no object", doll->GetID()); continue; } - psCharAppearance p(psengine->GetObjectRegistry()); - p.Clone(object->charApp); - p.SetMesh(dollObject); - p.Equip(slotname,equip.mesh,equip.part,equip.partMesh,equip.texture); + psCharAppearance* p = doll->GetCharApp(); + p->Clone(object->charApp); + p->SetMesh(dollObject); + p->Equip(slotname,equip.mesh,equip.part,equip.partMesh,equip.texture); } } } @@ -479,15 +477,15 @@ continue; } - psCharAppearance p(psengine->GetObjectRegistry()); - p.SetMesh(dollObject); - p.Clone(object->charApp); - p.Dequip(slotname,equip.mesh,equip.part,equip.partMesh,equip.texture); + psCharAppearance* p = doll->GetCharApp(); + p->SetMesh(dollObject); + p->Clone(object->charApp); + p->Dequip(slotname,equip.mesh,equip.part,equip.partMesh,equip.texture); } } object->charApp->Dequip(slotname,equip.mesh,equip.part,equip.partMesh,equip.texture); - } + } } void psClientCharManager::HandleEffectStop(MsgEntry* me) Modified: trunk/src/client/psengine.cpp =================================================================== --- trunk/src/client/psengine.cpp 2008-12-24 16:05:32 UTC (rev 2768) +++ trunk/src/client/psengine.cpp 2008-12-24 19:05:27 UTC (rev 2769) @@ -622,7 +622,7 @@ threadedLoading = !psengine->GetConfig()->GetBool("ThreadManager.AlwaysRunNow"); loader = new Loader(); - Loader::GetSingleton().Init(object_reg, preloadModels, gfxFeatures, 500); + Loader::GetSingleton().Init(object_reg, preloadModels, gfxFeatures, 200); if(threadedLoading) { Modified: trunk/src/client/zonehandler.cpp =================================================================== --- trunk/src/client/zonehandler.cpp 2008-12-24 16:05:32 UTC (rev 2768) +++ trunk/src/client/zonehandler.cpp 2008-12-24 19:05:27 UTC (rev 2769) @@ -220,7 +220,7 @@ { haveNewPos = false; } - else if (FindLoadWindow()) + else if(psengine->IsGameLoaded() && FindLoadWindow()) { loadWindow->SetAlwaysOnTop(true); loadWindow->Clear(); Modified: trunk/src/common/paws/pawsobjectview.cpp =================================================================== --- trunk/src/common/paws/pawsobjectview.cpp 2008-12-24 16:05:32 UTC (rev 2768) +++ trunk/src/common/paws/pawsobjectview.cpp 2008-12-24 19:05:27 UTC (rev 2769) @@ -33,22 +33,17 @@ #include "util/log.h" #include "util/psconst.h" -int pawsObjectView::idName = 0; - pawsObjectView::pawsObjectView() { engine = csQueryRegistry<iEngine > ( PawsManager::GetSingleton().GetObjectRegistry()); - object = NULL; ID = 0; - idName++; - realName.Format("NAME%d", idName); - rotateTime = orgTime = 0; rotateRadians = orgRadians = 0; camRotate = 0.0f; objectPos = csVector3(0,0,0); // Center of podium cameraMod = csVector3(0,0,0); + charApp = NULL; loadedMap = false; spinMouse = false; @@ -61,8 +56,10 @@ pawsObjectView::~pawsObjectView() { - engine->RemoveCollection(realName); - idName--; + if(col->GetRefCount() == 2) + { + engine->RemoveCollection(col); + } } bool pawsObjectView::Setup(iDocumentNode* node ) @@ -128,6 +125,7 @@ csRef<iThreadedLoader> loader = csQueryRegistry<iThreadedLoader> ( PawsManager::GetSingleton().GetObjectRegistry()); csRef<iVFS> VFS = csQueryRegistry<iVFS> ( PawsManager::GetSingleton().GetObjectRegistry()); + col = engine->CreateCollection(sector); stage = engine->FindSector( sector ); if ( !stage ) @@ -135,9 +133,6 @@ csRef<iDocumentSystem> xml ( csQueryRegistry<iDocumentSystem> (PawsManager::GetSingleton().GetObjectRegistry())); - // Create/Get collection - iCollection* col = engine->CreateCollection(realName); - csRef<iDocument> doc = xml->CreateDocument(); csString filename = map; filename.Append("/world"); @@ -170,9 +165,27 @@ return false; } + static uint sectorCount = 0; + meshSector = engine->CreateSector( csString(sector).AppendFmt("%u", sectorCount++)); + + iLightList* lightList = meshSector->GetLights(); + iLightList* stageLightList = stage->GetLights(); + + for(int i=0; i<stageLightList->GetCount(); i++) + { + lightList->Add(stageLightList->Get(i)); + } + + meshView = csPtr<iView> (new csView( engine, PawsManager::GetSingleton().GetGraphics3D() )); + meshView->GetCamera()->SetSector(meshSector); + meshView->GetCamera()->GetTransform().SetOrigin(csVector3(0, 1, -distance)); + + meshView->SetRectangle(screenFrame.xmin, screenFrame.ymin, + screenFrame.Width(),screenFrame.Height()); + view = csPtr<iView> (new csView( engine, PawsManager::GetSingleton().GetGraphics3D() )); view->GetCamera()->SetSector(stage); - view->GetCamera()->GetTransform().SetOrigin(csVector3(0,1,-distance)); + view->GetCamera()->GetTransform().SetOrigin(csVector3(0, 1, -distance)); view->SetRectangle(screenFrame.xmin, screenFrame.ymin, screenFrame.Width(), screenFrame.Height()); @@ -209,7 +222,8 @@ if(wrapper) { - object = engine->CreateMeshWrapper (wrapper, "PaperDoll", stage, csVector3(0,0,0) ); + iSector* sector = loadedMap ? meshSector : stage; + mesh = engine->CreateMeshWrapper (wrapper, "PaperDoll", stage, csVector3(0,0,0) ); } } @@ -217,7 +231,7 @@ { if(wrapper) { - View(wrapper->GetFactory()); + View(wrapper->GetFactory()); } } @@ -314,6 +328,23 @@ view->Draw(); + if ( loadedMap ) + { + og3d = meshView->GetContext(); + + meshView->SetContext(PawsManager::GetSingleton().GetGraphics3D()); + + meshView->SetRectangle(screenFrame.xmin, + PawsManager::GetSingleton().GetGraphics3D()->GetHeight() - screenFrame.ymax , + screenFrame.Width(), screenFrame.Height()); + meshView->GetPerspectiveCamera()->SetPerspectiveCenter((float)(screenFrame.xmin+(screenFrame.Width() >> 1))/graphics2D->GetWidth(), + 1-(float)(screenFrame.ymin+(screenFrame.Height() >> 1))/graphics2D->GetHeight()); + + meshView->GetCamera()->GetTransform().SetOrigin(cameraPosition); + meshView->GetCamera()->GetTransform().LookAt(lookingAt, csVector3(0, 1, 0)); + meshView->Draw(); + } + PawsManager::GetSingleton().GetGraphics3D()->BeginDraw( CSDRAW_2DGRAPHICS ); view->SetContext( og3d ); @@ -403,6 +434,24 @@ view->Draw(); + if ( loadedMap ) + { + og3d = meshView->GetContext(); + + meshView->SetContext(PawsManager::GetSingleton().GetGraphics3D()); + + meshView->SetRectangle(screenFrame.xmin, + PawsManager::GetSingleton().GetGraphics3D()->GetHeight() - screenFrame.ymax , + screenFrame.Width(), screenFrame.Height()); + + meshView->GetPerspectiveCamera()->SetPerspectiveCenter((float)(screenFrame.xmin+(screenFrame.Width() >> 1))/graphics2D->GetWidth(), + 1-(float)(screenFrame.ymin+(screenFrame.Height() >> 1))/graphics2D->GetHeight()); + + meshView->GetCamera()->GetTransform().SetOrigin(camera); + meshView->GetCamera()->GetTransform().LookAt(objectPos - camera + cameraMod, csVector3(0, 1, 0)); + meshView->Draw(); + } + PawsManager::GetSingleton().GetGraphics3D()->BeginDraw( CSDRAW_2DGRAPHICS ); view->SetContext( og3d ); @@ -466,6 +515,6 @@ if(mesh) { stage->GetMeshes()->Remove(mesh); - engine->GetMeshes()->Remove(mesh); + col->Remove(mesh->QueryObject()); } } Modified: trunk/src/common/paws/pawsobjectview.h =================================================================== --- trunk/src/common/paws/pawsobjectview.h 2008-12-24 16:05:32 UTC (rev 2768) +++ trunk/src/common/paws/pawsobjectview.h 2008-12-24 19:05:27 UTC (rev 2769) @@ -36,6 +36,8 @@ #include "pawswidget.h" +class psCharAppearance; + /** This widget is used to view a mesh in it's own seperate world. */ class pawsObjectView : public pawsWidget @@ -83,7 +85,7 @@ void Draw(); - iMeshWrapper* GetObject() { return object; } + iMeshWrapper* GetObject() { return mesh; } bool OnMouseDown(int button,int mod, int x, int y); bool OnMouseUp(int button,int mod, int x, int y); @@ -106,6 +108,9 @@ void SetID(unsigned int id) { ID = id; } unsigned int GetID() { return ID; } + void SetCharApp(psCharAppearance* cApp) { charApp = cApp; } + psCharAppearance* GetCharApp() { return charApp; } + private: /** @@ -134,12 +139,14 @@ csRef<iSector> stage; csRef<iView> view; csRef<iEngine> engine; - csRef<iMeshWrapper> object; + csRef<iMeshWrapper> mesh; + csRef<iCollection> col; + csRef<iSector> meshSector; + csRef<iView> meshView; + psCharAppearance* charApp; csVector3 objectPos; csVector3 cameraMod; - static int idName; - csString realName; void RotateDef(); // Used to reset to the values given by the controlling widget void RotateTemp(int speed,float radians); // Used to for example stop the rotate but not write the def values This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ven...@us...> - 2009-01-06 00:31:10
|
Revision: 2817 http://planeshift.svn.sourceforge.net/planeshift/?rev=2817&view=rev Author: Vengeance2001 Date: 2009-01-06 00:31:08 +0000 (Tue, 06 Jan 2009) Log Message: ----------- Now Paladin detects speed hacks and kicks you off the server if you run too quickly for more than a few seconds. Needs to be tested more by the Testing team if possible for false positives mostly. Modified Paths: -------------- trunk/src/common/engine/linmove.cpp trunk/src/server/adminmanager.cpp trunk/src/server/client.cpp trunk/src/server/client.h trunk/src/server/entitymanager.cpp trunk/src/server/entitymanager.h trunk/src/server/paladinjr.cpp trunk/src/server/paladinjr.h trunk/src/server/psserverdr.cpp Modified: trunk/src/common/engine/linmove.cpp =================================================================== --- trunk/src/common/engine/linmove.cpp 2009-01-05 22:46:17 UTC (rev 2816) +++ trunk/src/common/engine/linmove.cpp 2009-01-06 00:31:08 UTC (rev 2817) @@ -291,7 +291,6 @@ int psLinearMovement::MoveSprite (float delta) { - //float local_max_interval; int ret = PS_MOVE_SUCCEED; csReversibleTransform fulltransf = mesh->GetMovable () @@ -299,41 +298,27 @@ const csMatrix3& transf = fulltransf.GetT2O (); float yrot = Matrix2YRot (transf); - - // Make sure time moves forward at least at this rate - - //float temp3=(vel.y==0.0f) - // ? MAX_CD_INTERVAL - // : ABS (topSize.y/vel.y); - - //float temp2=MIN (temp3, (vel.x==0.0f) - // ? MAX_CD_INTERVAL - // : ABS (topSize.x/vel.x)); - - //float temp1=MIN (temp2, (vel.z==0.0f) - // ? MAX_CD_INTERVAL - // : ABS (topSize.z/vel.z)); - - //float local_max_interval = - // MAX (temp1, MIN_CD_INTERVAL); - // Calculate the total velocity (body and world) in OBJECT space. csVector3 bodyVel (fulltransf.Other2ThisRelative (velWorld) + velBody); float local_max_interval = - MIN (MIN ((bodyVel.y==0.0f) - ? MAX_CD_INTERVAL - : ABS (intervalSize.y/bodyVel.y), (bodyVel.x==0.0f) - ? MAX_CD_INTERVAL - : ABS (intervalSize.x/bodyVel.x)), (bodyVel.z==0.0f) - ? MAX_CD_INTERVAL - : ABS (intervalSize.z/bodyVel.z)); + MIN (MIN ( (bodyVel.y==0.0f) ? MAX_CD_INTERVAL : ABS (intervalSize.y/bodyVel.y), + (bodyVel.x==0.0f) ? MAX_CD_INTERVAL : ABS (intervalSize.x/bodyVel.x) + ),(bodyVel.z==0.0f) ? MAX_CD_INTERVAL : ABS (intervalSize.z/bodyVel.z) + ); // Compensate for speed local_max_interval /= speed; // Err on the side of safety (95% error margin) local_max_interval *= 0.95f; + //printf("local_max_interval=%f, bodyVel is %1.2f, %1.2f, %1.2f\n",local_max_interval, bodyVel.x, bodyVel.y, bodyVel.z); + //printf("velWorld is %1.2f, %1.2f, %1.2f\n", velWorld.x, velWorld.y, velWorld.z); + //printf("velBody is %1.2f, %1.2f, %1.2f\n", velBody.x, velBody.y, velBody.z); + + // Sanity check on time interval here. Something is messing it up. -KWF + //local_max_interval = MAX(local_max_interval,0.1F); + if (colldet) { while (delta > local_max_interval) @@ -415,6 +400,9 @@ local_max_interval /= speed; // Err on the side of safety (95% error margin) local_max_interval *= 0.95f; + + // Sanity check on time interval here. Something is messing it up. -KWF + // local_max_interval = MAX(local_max_interval,0.1F); } } @@ -1097,6 +1085,9 @@ void psLinearMovement::AddVelocity (const csVector3& vel) { + if (vel.Norm() > 100) + printf("Garbage data in AddVel!\n"); + // Y movement here can be used for lift and gravity effects. velWorld += vel; } Modified: trunk/src/server/adminmanager.cpp =================================================================== --- trunk/src/server/adminmanager.cpp 2009-01-05 22:46:17 UTC (rev 2816) +++ trunk/src/server/adminmanager.cpp 2009-01-06 00:31:08 UTC (rev 2817) @@ -1866,7 +1866,7 @@ info.AppendFmt("total time connected is %1.1f hours", timeConnected ); - info.AppendFmt(" has had %d exploits flagged.", client->GetFlagCount()); + info.AppendFmt(" has had %d cheats flagged.", client->GetDetectedCheatCount()); if(banned) { Modified: trunk/src/server/client.cpp =================================================================== --- trunk/src/server/client.cpp 2009-01-05 22:46:17 UTC (rev 2816) +++ trunk/src/server/client.cpp 2009-01-06 00:31:08 UTC (rev 2817) @@ -65,7 +65,7 @@ lastInviteTime = 0; spamPoints = 0; clientnum = 0; - flags = 0; + detectedCheatCount = 0; nextFloodHistoryIndex = 0; Modified: trunk/src/server/client.h =================================================================== --- trunk/src/server/client.h 2009-01-05 22:46:17 UTC (rev 2816) +++ trunk/src/server/client.h 2009-01-06 00:31:08 UTC (rev 2817) @@ -353,9 +353,8 @@ bool LocationIsDisplaying() { return locationIsDisplaying; } /// Give a warning to the client silently. Capped at 10000. - void FlagExploit() {if(flags < 10000) flags++; } - - int GetFlagCount() { return flags;} + void CountDetectedCheat() {if (detectedCheatCount < 10000) detectedCheatCount++; } + int GetDetectedCheatCount() { return detectedCheatCount;} protected: @@ -413,10 +412,6 @@ bool hasBeenWarned; bool hasBeenPenalized; - // State information for merchants - // TradingStatus tradingStatus; - // int merchantID; - // Path edit global vars for client csString waypointPathName; int waypointPathIndex; @@ -435,7 +430,7 @@ /// Potential number of exploits automatically detected. /// This needs more work as it's only a preliminary measure so far. - int flags; + int detectedCheatCount; }; #endif Modified: trunk/src/server/entitymanager.cpp =================================================================== --- trunk/src/server/entitymanager.cpp 2009-01-05 22:46:17 UTC (rev 2816) +++ trunk/src/server/entitymanager.cpp 2009-01-06 00:31:08 UTC (rev 2817) @@ -949,31 +949,6 @@ } - -void EntityManager::HandleMessage(MsgEntry* me,Client *client) -{ - /**************************** - switch(me->GetType()) - { - case MSGTYPE_USERACTION: - HandleUserAction( me ); - break; - case MSGTYPE_PERSIST_WORLD_REQUEST: - HandleWorld( me ); - break; - case MSGTYPE_PERSIST_ACTOR_REQUEST: - HandleActor( me ); - break; - case MSGTYPE_PERSIST_ALL: - HandleAllRequest( me ); - break; - case MSGTYPE_REQUESTMOVEMENTS: - SendMovementInfo( me->clientnum ); - break; - } - ****************************/ -} - void EntityManager::HandleAllRequest(MsgEntry* me, Client *client) { // This is not available to regular clients! Modified: trunk/src/server/entitymanager.h =================================================================== --- trunk/src/server/entitymanager.h 2009-01-05 22:46:17 UTC (rev 2816) +++ trunk/src/server/entitymanager.h 2009-01-06 00:31:08 UTC (rev 2817) @@ -122,7 +122,7 @@ psCharacter *owner, bool transient); - virtual void HandleMessage(MsgEntry* me,Client *client); + virtual void HandleMessage(MsgEntry* me,Client *client) {}; bool RemoveActor(gemObject *actor); Modified: trunk/src/server/paladinjr.cpp =================================================================== --- trunk/src/server/paladinjr.cpp 2009-01-05 22:46:17 UTC (rev 2816) +++ trunk/src/server/paladinjr.cpp 2009-01-06 00:31:08 UTC (rev 2817) @@ -65,26 +65,27 @@ maxVelocity.z *= maxMod.z; // Running forward while strafing + maxSpeed = sqrtf(maxVelocity.z * maxVelocity.z + maxVelocity.x * maxVelocity.x); maxSpeed = 1; - watchTime = configmanager->GetInt("PlaneShift.Paladin.WatchTime", 30000); target = NULL; entitymanager = celbase; } -void PaladinJr::PredictClient(Client* client, psDRMessage& currUpdate) +bool PaladinJr::ValidateMovement(Client* client, psDRMessage& currUpdate) { // Don't check GMs/Devs - if(client->GetSecurityLevel()) - return; + //if(client->GetSecurityLevel()) + // return; // Speed check always enabled - SpeedCheck(client, currUpdate); + if (!SpeedCheck(client, currUpdate)) + return false; // DON'T USE THIS CLIENT POINTER AGAIN if (!enabled) - return; + return true; checkClient = false; @@ -108,7 +109,7 @@ #endif checked.DeleteAll(); } - return; + return true; } if (!target) @@ -119,10 +120,10 @@ #ifdef PALADIN_DEBUG CPrintf(CON_DEBUG, "Now checking client %d\n", target->GetClientNum()); #endif - return; + return true; } else if (target != client) - return; + return true; float yrot; iSector* sector; @@ -136,12 +137,12 @@ //if (vel.x == 0 && vel.z == 0) //{ - // // Minimum speed to cope with client-side timing discrepencies + // // Minimum speed to cope with client-side timing discrepancies // vel.x = vel.z = -1; //} // Paladin Jr needs CD enabled on the entity. - client->GetActor()->pcmove->UseCD(true); + //kwf client->GetActor()->pcmove->UseCD(true); client->GetActor()->pcmove->SetVelocity(vel); // TODO: Assuming maximum lag, need to add some kind of lag prediction here. @@ -165,13 +166,13 @@ lastUpdate = currUpdate; checkClient = true; - return; + return true; } -void PaladinJr::CheckClient(Client* client) +bool PaladinJr::CheckCollDetection(Client* client) { if (!enabled || !checkClient || client->GetSecurityLevel()) - return; + return true; csVector3 pos; float yrot; @@ -208,9 +209,11 @@ angVel.x, angVel.y, angVel.z, PALADIN_VERSION); psserver->GetLogCSV()->Write(CSV_PALADIN, buf); } + + return true; } -void PaladinJr::SpeedCheck(Client* client, psDRMessage& currUpdate) +bool PaladinJr::SpeedCheck(Client* client, psDRMessage& currUpdate) { csVector3 oldpos; // Dummy variables @@ -220,25 +223,27 @@ client->GetActor()->pcmove->GetLastClientPosition (oldpos, yrot, sector); // If no previous observations then we have nothing to check against. - if(!sector) - return; + if (!sector) + return true; float dist = sqrt (pow((currUpdate.pos.x - oldpos.x), 2.0f) + pow((currUpdate.pos.z - oldpos.z), 2.0f)); csTicks timedelta = client->GetActor()->pcmove->ClientTimeDiff(); - float max_noncheat_distance=maxSpeed*timedelta/1000; + float max_noncheat_distance = maxSpeed*timedelta/1000; + float lag_distance = maxSpeed*client->accumulatedLag/1000; - if (fabs(currUpdate.vel.x) <= maxVelocity.x && currUpdate.vel.y <= maxVelocity.y && fabs(currUpdate.vel.z) <= maxVelocity.z && dist<max_noncheat_distance - + maxSpeed*client->accumulatedLag/1000) + if (fabs(currUpdate.vel.x) <= maxVelocity.x && + currUpdate.vel.y <= maxVelocity.y && + fabs(currUpdate.vel.z) <= maxVelocity.z && + dist<max_noncheat_distance + lag_distance) { if (dist < max_noncheat_distance) { // Calculate the "unused movement time" here and add it to the // accumulated lag. - client->accumulatedLag += (csTicks)((max_noncheat_distance-dist) - * 1000.0f/maxSpeed); + client->accumulatedLag += (csTicks)((max_noncheat_distance-dist) * 1000.0f/maxSpeed); if (client->accumulatedLag > MAX_ACCUMULATED_LAG) client->accumulatedLag = MAX_ACCUMULATED_LAG; } @@ -249,10 +254,10 @@ client->accumulatedLag-=(csTicks)((dist-max_noncheat_distance) * 1000.0f/maxSpeed); } + //printf("Accumulated lag: %u\n",client->accumulatedLag); } else { - // Report cheater csVector3 vel; csVector3 angVel; @@ -263,15 +268,15 @@ // Player has probably been warped if (sector != currUpdate.sector) { - return; + return true; //sectorName.Append(" to "); //sectorName.Append(currUpdate.sectorName); //type = "Possible Speed Violation"; } - else if(fabs(currUpdate.vel.x) > maxVelocity.x || currUpdate.vel.y > maxVelocity.y || fabs(currUpdate.vel.z) > maxVelocity.z) + else if (dist<max_noncheat_distance + lag_distance) type = "Speed Violation (Hack confirmed)"; else - type = "Speed Violation"; + type = "Distance Violation"; vel = client->GetActor()->pcmove->GetVelocity(); client->GetActor()->pcmove->GetAngularVelocity(angVel); @@ -280,10 +285,24 @@ max_noncheat_distance, max_noncheat_distance, currUpdate.pos.x - oldpos.x, currUpdate.pos.y - oldpos.y, currUpdate.pos.z - oldpos.z, vel.x, vel.y, vel.z, angVel.x, angVel.y, angVel.z, PALADIN_VERSION); + psserver->GetLogCSV()->Write(CSV_PALADIN, buf); Debug5(LOG_CHEAT, client->GetClientNum(),"Player %s traversed %1.2fm in %u msec with an accumulated lag allowance of %u ms. Cheat detected!\n", client->GetName (),dist,timedelta,client->accumulatedLag); + + client->CountDetectedCheat(); + if (client->GetDetectedCheatCount() % 25 == 0) + { + psserver->SendSystemError(client->GetClientNum(),"You have been flagged as using speed hacks. You will be disconnected if you continue."); + } + if (client->GetDetectedCheatCount() > 100) + { + printf("Disconnecting a cheating client.\n"); + psserver->RemovePlayer(client->GetClientNum(),"Paladin has kicked you from the server for cheating."); + return false; // DON'T USE THIS CLIENT PTR ANYMORE! + } } + return true; } Modified: trunk/src/server/paladinjr.h =================================================================== --- trunk/src/server/paladinjr.h 2009-01-05 22:46:17 UTC (rev 2816) +++ trunk/src/server/paladinjr.h 2009-01-06 00:31:08 UTC (rev 2817) @@ -37,10 +37,11 @@ public: // Extrapolate the current position from last DR packet - void PredictClient(Client*, psDRMessage& drmsg); + bool ValidateMovement(Client*, psDRMessage& drmsg); + // Compare extrapolated displacement with new displacement from new DR packet // Should be called after actor has been updated with newest recieved DR packet - void CheckClient(Client*); + bool CheckCollDetection(Client*); void Initialize(EntityManager* celbase); PaladinJr() @@ -58,7 +59,7 @@ bool enabled; unsigned int watchTime; - void SpeedCheck(Client* client, psDRMessage& currUpdate); + bool SpeedCheck(Client* client, psDRMessage& currUpdate); EntityManager *entitymanager; Modified: trunk/src/server/psserverdr.cpp =================================================================== --- trunk/src/server/psserverdr.cpp 2009-01-05 22:46:17 UTC (rev 2816) +++ trunk/src/server/psserverdr.cpp 2009-01-06 00:31:08 UTC (rev 2817) @@ -149,19 +149,19 @@ actor->MulticastDRUpdate(); } -void psServerDR::HandleMessage (MsgEntry* me,Client *client) +void psServerDR::HandleMessage(MsgEntry* me,Client *client) { psDRMessage drmsg(me,CacheManager::GetSingleton().GetMsgStrings(),EntityManager::GetSingleton().GetEngine() ); if (!drmsg.valid) { - Debug2(LOG_NET,me->clientnum,"Received unparsable psDRMessage from client %u.\n",me->clientnum); + Error2("Received unparsable psDRMessage from client %u.\n",me->clientnum); return; } gemActor *actor = client->GetActor(); if (actor == NULL) { - Error1("Recieved DR data for NULL actor."); + Error1("Received DR data for NULL actor."); return; } @@ -169,7 +169,7 @@ { if (drmsg.worldVel.y > 0) { - client->FlagExploit(); // This DR data may be an exploit but may also be valid from lag. + client->CountDetectedCheat(); // This DR data may be an exploit but may also be valid from lag. actor->pcmove->AddVelocity(csVector3(0,-1,0)); actor->UpdateDR(); actor->MulticastDRUpdate(); @@ -213,7 +213,8 @@ return; } - paladin->PredictClient(client, drmsg); + if (!paladin->ValidateMovement(client, drmsg)) // client ptr has been deleted if this is false + return; // Go ahead and update the server version if (!actor->SetDRData(drmsg)) // out of date message if returns false @@ -276,7 +277,7 @@ actor->GetMulticastClients(), me->clientnum,PROX_LIST_ANY_RANGE); - paladin->CheckClient(client); + paladin->CheckCollDetection(client); // Swap lines for easy Death Penalty testing. //if (strcmp(drmsg.sector->QueryObject()->GetName(), "NPCroom1") == 0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ven...@us...> - 2009-01-06 07:33:58
|
Revision: 2822 http://planeshift.svn.sourceforge.net/planeshift/?rev=2822&view=rev Author: Vengeance2001 Date: 2009-01-06 07:33:57 +0000 (Tue, 06 Jan 2009) Log Message: ----------- A couple of fixes to Paladin speed check. Thanks to Aiken for his help in finding these. Modified Paths: -------------- trunk/src/client/psmovement.cpp trunk/src/server/paladinjr.cpp Modified: trunk/src/client/psmovement.cpp =================================================================== --- trunk/src/client/psmovement.cpp 2009-01-06 05:59:01 UTC (rev 2821) +++ trunk/src/client/psmovement.cpp 2009-01-06 07:33:57 UTC (rev 2822) @@ -346,7 +346,7 @@ newmove->name = name; newmove->motion.move = base_move; newmove->motion.rotate = base_rotate; - + CS_ASSERT(id < sizeof(activeMoves)*8); moves.Put(id,newmove); } Modified: trunk/src/server/paladinjr.cpp =================================================================== --- trunk/src/server/paladinjr.cpp 2009-01-06 05:59:01 UTC (rev 2821) +++ trunk/src/server/paladinjr.cpp 2009-01-06 07:33:57 UTC (rev 2822) @@ -66,7 +66,7 @@ // Running forward while strafing maxSpeed = sqrtf(maxVelocity.z * maxVelocity.z + maxVelocity.x * maxVelocity.x); - maxSpeed = 1; + //maxSpeed = 1; watchTime = configmanager->GetInt("PlaneShift.Paladin.WatchTime", 30000); @@ -226,14 +226,15 @@ if (!sector) return true; - float dist = sqrt (pow((currUpdate.pos.x - oldpos.x), 2.0f) + - pow((currUpdate.pos.z - oldpos.z), 2.0f)); + float dist = sqrt ( (currUpdate.pos.x - oldpos.x)*(currUpdate.pos.x - oldpos.x) + + (currUpdate.pos.z - oldpos.z)*(currUpdate.pos.z - oldpos.z) ); csTicks timedelta = client->GetActor()->pcmove->ClientTimeDiff(); float max_noncheat_distance = maxSpeed*timedelta/1000; float lag_distance = maxSpeed*client->accumulatedLag/1000; + if (fabs(currUpdate.vel.x) <= maxVelocity.x && currUpdate.vel.y <= maxVelocity.y && fabs(currUpdate.vel.z) <= maxVelocity.z && @@ -258,6 +259,10 @@ } else { + printf("Went %1.2f in %u ticks when %1.2f was expected plus %1.2f allowed lag distance (%1.2f)\n", dist, timedelta, max_noncheat_distance, lag_distance, max_noncheat_distance+lag_distance); + printf("Z Vel is %1.2f\n", currUpdate.vel.z); + printf("MaxSpeed is %1.2f\n", maxSpeed); + // Report cheater csVector3 vel; csVector3 angVel; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ven...@us...> - 2009-01-07 08:00:48
|
Revision: 2834 http://planeshift.svn.sourceforge.net/planeshift/?rev=2834&view=rev Author: Vengeance2001 Date: 2009-01-07 08:00:45 +0000 (Wed, 07 Jan 2009) Log Message: ----------- - Fixed crash if the speex plugin isn't available, which has the effect of the file being found but the data still unable to be loaded (crashes the client). - Fixed crash in npc /give check for frozen targetClient - Now quests break up dialog into different say commands, one sentence at a time. The objective of this is to make the chat (and chat bubbles) more readable and give better pacing with the eventual audio files. Modified Paths: -------------- trunk/src/client/psmovement.cpp trunk/src/client/sound/pssoundmngr.cpp trunk/src/server/bulkobjects/dictionary.cpp trunk/src/server/exchangemanager.cpp Modified: trunk/src/client/psmovement.cpp =================================================================== --- trunk/src/client/psmovement.cpp 2009-01-07 02:24:57 UTC (rev 2833) +++ trunk/src/client/psmovement.cpp 2009-01-07 08:00:45 UTC (rev 2834) @@ -341,12 +341,15 @@ base_rotate.x,base_rotate.y,base_rotate.z); #endif + base_move.z *= 1.5; + psMovement* newmove = new psMovement; newmove->id = id; newmove->name = name; newmove->motion.move = base_move; newmove->motion.rotate = base_rotate; + CS_ASSERT(id < sizeof(activeMoves)*8); moves.Put(id,newmove); } Modified: trunk/src/client/sound/pssoundmngr.cpp =================================================================== --- trunk/src/client/sound/pssoundmngr.cpp 2009-01-07 02:24:57 UTC (rev 2833) +++ trunk/src/client/sound/pssoundmngr.cpp 2009-01-07 08:00:45 UTC (rev 2834) @@ -272,7 +272,11 @@ Error2("Sound '%s' not found!", name); return NULL; } - + if (!handle->snddata) + { + Error2("Sound '%s' was found but could not be loaded!", name); + return NULL; + } csRef<iSndSysStream> sndstream = soundSystem->CreateStream(handle->snddata, CS_SND3D_DISABLE); if (!sndstream) { Modified: trunk/src/server/bulkobjects/dictionary.cpp =================================================================== --- trunk/src/server/bulkobjects/dictionary.cpp 2009-01-07 02:24:57 UTC (rev 2833) +++ trunk/src/server/bulkobjects/dictionary.cpp 2009-01-07 08:00:45 UTC (rev 2834) @@ -601,6 +601,10 @@ } } +#ifndef min +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif + NpcResponse *NPCDialogDict::AddResponse(const char *response_text, const char *pronoun_him, const char *pronoun_her, @@ -620,70 +624,78 @@ csString opStr; - if (strchr(response_text,'[')) + size_t start=0,end=0; + opStr = "<response>"; + csString resp(response_text); + + printf("\nGot: %s\n",response_text); + + while (end != resp.Length() ) { - size_t start=0,end=0; - opStr = "<response>"; - csString resp(response_text); + while (start < resp.Length() && (resp.GetAt(start) == ']' || resp.GetAt(start) == ' ')) + start++; + if (start == resp.Length()) + break; - while (end != resp.Length() ) + end = (int)min(resp.Find("[", start),resp.Find(". ", start)); // action delimiter or sentence delimiter whichever is first + if (end == SIZET_NOT_FOUND) + end = resp.Length(); + if (end < resp.Length() && resp.GetAt(end)=='.') // include the period in this substring + end++; + + if (end-start > 0) { - if (resp.GetAt(start) == ']') - start++; - end = (int)resp.Find("[", start); // action delimiter - if (end == SIZET_NOT_FOUND) - end = resp.Length(); + csString saySegment; + resp.SubString(saySegment,start,end-start); // pull out the part before the [ ] + printf("Say: %s\n",(const char *)saySegment); + opStr.AppendFmt("<say text=\"%s\"/>", saySegment.GetDataSafe() ); + } + if (end == resp.Length()) // stop if at end of string already + break; - if (end-start > 0) - { - csString saySegment; - resp.SubString(saySegment,start,end-start); // pull out the part before the [ ] - opStr.AppendFmt("<say text=\"%s\"/>", saySegment.GetDataSafe() ); - } - if (end == resp.Length()) - break; + if (end > 0 && resp.GetAt(end-1)=='.' && resp.GetAt(end) != '[') // skip action brackets if this was a sentence break + { + start = end; + continue; + } - // Now get the part in brackets - start = end; - end = resp.Find("]", start); // find end of action - if (end == SIZET_NOT_FOUND) + // Now get the part in brackets + start = end; + end = resp.Find("]", start); // find end of action + if (end == SIZET_NOT_FOUND) + { + Error2("Unmatched open '[' in npc response %s.", response_text); + delete newresp; + return NULL; + } + + if (end - start > 1) + { + csString actionSegment; + resp.SubString(actionSegment,start+1,end-start-1); + // If action does not start with npc's name, it is a 3rd person statement, not /me + if (strncasecmp(actionSegment,npc_name,strlen(npc_name))) { - Error2("Unmatched open '[' in npc response %s.", response_text); - delete newresp; - return NULL; + opStr.AppendFmt("<narrate text=\"%s\"/>", actionSegment.GetDataSafe() ); } - - if (end - start > 1) + else // now look for /me or /my because the npc name matches { - csString actionSegment; - resp.SubString(actionSegment,start+1,end-start-1); - // If action does not start with npc's name, it is a 3rd person statement, not /me - if (strncasecmp(actionSegment,npc_name,strlen(npc_name))) + size_t spc = actionSegment.FindFirst(" "); + if (resp[strlen(npc_name)] == '\'') // apostrophe after name means /my { - opStr.AppendFmt("<narrate text=\"%s\"/>", actionSegment.GetDataSafe() ); + actionSegment.DeleteAt(0,spc+1); + opStr.AppendFmt("<actionmy text=\"%s\"/>", actionSegment.GetDataSafe() ); } - else // now look for /me or /my because the npc name matches + else // this is a /me command { - size_t spc = actionSegment.FindFirst(" "); - if (resp[strlen(npc_name)] == '\'') // apostrophe after name means /my - { - actionSegment.DeleteAt(0,spc+1); - opStr.AppendFmt("<actionmy text=\"%s\"/>", actionSegment.GetDataSafe() ); - } - else // this is a /me command - { - actionSegment.DeleteAt(0,spc+1); - opStr.AppendFmt("<action text=\"%s\"/>", actionSegment.GetDataSafe() ); - } + actionSegment.DeleteAt(0,spc+1); + opStr.AppendFmt("<action text=\"%s\"/>", actionSegment.GetDataSafe() ); } } - start = end; } + start = end; } - else // simple case doesn't have /me actions in brackets [ ] - { - newresp->response[0] = response_text; - } + newresp->him = pronoun_him; newresp->her = pronoun_her; newresp->it = pronoun_it; Modified: trunk/src/server/exchangemanager.cpp =================================================================== --- trunk/src/server/exchangemanager.cpp 2009-01-07 02:24:57 UTC (rev 2833) +++ trunk/src/server/exchangemanager.cpp 2009-01-07 08:00:45 UTC (rev 2834) @@ -1374,12 +1374,6 @@ return; } - if(targetClient->IsFrozen()) - { - psserver->SendSystemInfo(client->GetClientNum(), "% was frozen by a GM and cannot trade", target->GetName()); - return; - } - // if the command was "/give": if (!withPlayer) { @@ -1405,9 +1399,15 @@ // if the command was "/trade": else { + if(targetClient->IsFrozen()) + { + psserver->SendSystemInfo(client->GetClientNum(), "% was frozen by a GM and cannot trade", target->GetName()); + return; + } + if ( target->GetNPCPtr() ) { - psserver->SendSystemError(client->GetClientNum(), "You can trade with other players only"); + psserver->SendSystemError(client->GetClientNum(), "You can trade with other players only."); return; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wel...@us...> - 2009-01-14 09:17:53
|
Revision: 2885 http://planeshift.svn.sourceforge.net/planeshift/?rev=2885&view=rev Author: weltall2 Date: 2009-01-14 09:17:51 +0000 (Wed, 14 Jan 2009) Log Message: ----------- Made npc rotate back to their position when stopping talking with them and some comment fixes all by kougaro Modified Paths: -------------- trunk/src/client/pscamera.cpp trunk/src/client/pscharcontrol.h trunk/src/client/psclientchar.cpp trunk/src/server/bulkobjects/psactionlocationinfo.h trunk/src/server/gem.h Modified: trunk/src/client/pscamera.cpp =================================================================== --- trunk/src/client/pscamera.cpp 2009-01-14 06:53:52 UTC (rev 2884) +++ trunk/src/client/pscamera.cpp 2009-01-14 09:17:51 UTC (rev 2885) @@ -252,9 +252,11 @@ if((angle-npcrot) < 3.14159F && (angle-npcrot) > -3.14159F && velNormSquared == 0) + { + psengine->GetCharManager()->StoreTarget(); target->SetPosition(target->GetPosition(), angle, target->GetSector()); + } - npcModeTarget = target; npcModePosition = actor->GetMesh()->GetMovable()->GetFullPosition(); SetCameraMode(CAMERA_NPCTALK); @@ -1443,6 +1445,7 @@ psClientCharManager* clientChar = psengine->GetCharManager(); if (npcModeTarget != clientChar->GetTarget() || npcModePosition != actor->GetMesh()->GetMovable()->GetFullPosition()) { + clientChar->GetTargetStored()->SetPosition(clientChar->GetTargetStored()->GetPosition(), clientChar->GetOldRot(), clientChar->GetTargetStored()->GetSector()); SetCameraMode(lastCameraMode); break; } Modified: trunk/src/client/pscharcontrol.h =================================================================== --- trunk/src/client/pscharcontrol.h 2009-01-14 06:53:52 UTC (rev 2884) +++ trunk/src/client/pscharcontrol.h 2009-01-14 09:17:51 UTC (rev 2885) @@ -232,6 +232,7 @@ bool Initialize(); bool IsReady(); + ///Takes an event from psEngine, and dispatch it to either psControlManager or psMovementManager bool HandleEvent(iEvent& event); /// Provides access to the movement system Modified: trunk/src/client/psclientchar.cpp =================================================================== --- trunk/src/client/psclientchar.cpp 2009-01-14 06:53:52 UTC (rev 2884) +++ trunk/src/client/psclientchar.cpp 2009-01-14 09:17:51 UTC (rev 2885) @@ -385,6 +385,12 @@ Error1("Received psUserActionMessage for invalid object."); } +void psClientCharManager::StoreTarget() +{ + targetStored = target; + rotStored = targetStored->GetRotation(); +} + void psClientCharManager::HandlePlaySound( MsgEntry* me ) { csRef<iSoundManager> soundmanager = psengine->GetSoundManager(); Modified: trunk/src/server/bulkobjects/psactionlocationinfo.h =================================================================== --- trunk/src/server/bulkobjects/psactionlocationinfo.h 2009-01-14 06:53:52 UTC (rev 2884) +++ trunk/src/server/bulkobjects/psactionlocationinfo.h 2009-01-14 09:17:51 UTC (rev 2885) @@ -87,7 +87,7 @@ csString GetEnterScript() const { return enterScript; } void SetEnterScript(csString newScript) { enterScript = newScript; } - /// Returns the enterance type in entrance action location response string + /// Returns the entrance type in entrance action location response string csString GetEntranceType() const { return entranceType; } void SetEntranceType(csString newType) { entranceType = newType; } Modified: trunk/src/server/gem.h =================================================================== --- trunk/src/server/gem.h 2009-01-14 06:53:52 UTC (rev 2884) +++ trunk/src/server/gem.h 2009-01-14 09:17:51 UTC (rev 2885) @@ -768,7 +768,7 @@ virtual void Broadcast(int clientnum, bool control); /** - * /param control Set to true when sent to the controling client. + * @param control Set to true when sent to the controling client. */ virtual void Send( int clientnum, bool control, bool to_superclient ); virtual void SendGroupMessage(MsgEntry *me); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ven...@us...> - 2009-01-18 06:45:51
|
Revision: 2899 http://planeshift.svn.sourceforge.net/planeshift/?rev=2899&view=rev Author: Vengeance2001 Date: 2009-01-18 06:45:35 +0000 (Sun, 18 Jan 2009) Log Message: ----------- Fixing chat bubbles so that both the npc bubbles and the player menu popups are displayed. Modified Paths: -------------- trunk/src/client/chatbubbles.cpp trunk/src/server/usermanager.cpp Modified: trunk/src/client/chatbubbles.cpp =================================================================== --- trunk/src/client/chatbubbles.cpp 2009-01-18 06:44:41 UTC (rev 2898) +++ trunk/src/client/chatbubbles.cpp 2009-01-18 06:45:35 UTC (rev 2899) @@ -156,6 +156,8 @@ else if (type == "my") chat.chatType = CHATBUBBLE_MY; else if (type == "npc") + chat.chatType = CHAT_NPC; + else if (type == "npcinternal") chat.chatType = CHAT_NPCINTERNAL; // /tellnpc messages are now ignored and only /tellnpcinternal messages are displayed. These are normally sent in pairs. else if (type == "npc_me") chat.chatType = CHAT_NPC_ME; Modified: trunk/src/server/usermanager.cpp =================================================================== --- trunk/src/server/usermanager.cpp 2009-01-18 06:44:41 UTC (rev 2898) +++ trunk/src/server/usermanager.cpp 2009-01-18 06:45:35 UTC (rev 2899) @@ -1613,8 +1613,7 @@ if ( !client->GetActor()->IsNear( targetClient->GetActor(), ASSIST_MAX_DIST ) ) { - psserver->SendSystemInfo(clientnum, - "Specified player is too far away." ); + psserver->SendSystemInfo(clientnum,"Specified player is too far away." ); return; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ven...@us...> - 2009-01-18 16:30:47
|
Revision: 2903 http://planeshift.svn.sourceforge.net/planeshift/?rev=2903&view=rev Author: Vengeance2001 Date: 2009-01-18 16:30:44 +0000 (Sun, 18 Jan 2009) Log Message: ----------- Committing a fix by Nick Prassas (Loyni) for bug 2691. Thanks Nick! (Net Version bump) Modified Paths: -------------- trunk/src/client/guihandler.cpp trunk/src/client/psinventorycache.cpp trunk/src/client/psinventorycache.h trunk/src/common/net/messages.cpp trunk/src/common/net/messages.h trunk/src/server/bulkobjects/pscharinventory.cpp trunk/src/server/bulkobjects/pscharinventory.h trunk/src/server/psserverchar.cpp Modified: trunk/src/client/guihandler.cpp =================================================================== --- trunk/src/client/guihandler.cpp 2009-01-18 10:08:56 UTC (rev 2902) +++ trunk/src/client/guihandler.cpp 2009-01-18 16:30:44 UTC (rev 2903) @@ -65,6 +65,14 @@ { psGUIInventoryMessage incoming(me); + // drop inventory list, if its version is older than the current. + // this may happen due to UDP latency. + if (inventoryCache->GetInventoryVersion() >= incoming.version) + return; + + // Set new version in any case (LIST or UPDATE_LIST) + inventoryCache->SetInventoryVersion(incoming.version); + // merge the received inventory list into the client's inventory cache if (incoming.command == psGUIInventoryMessage::LIST) // for the whole lot { Modified: trunk/src/client/psinventorycache.cpp =================================================================== --- trunk/src/client/psinventorycache.cpp 2009-01-18 10:08:56 UTC (rev 2902) +++ trunk/src/client/psinventorycache.cpp 2009-01-18 16:30:44 UTC (rev 2903) @@ -21,7 +21,7 @@ #include "psinventorycache.h" #include "globals.h" -psInventoryCache::psInventoryCache () +psInventoryCache::psInventoryCache () : version(0) { msgHandler = psengine->GetMsgHandler(); EmptyInventory(); Modified: trunk/src/client/psinventorycache.h =================================================================== --- trunk/src/client/psinventorycache.h 2009-01-18 10:08:56 UTC (rev 2902) +++ trunk/src/client/psinventorycache.h 2009-01-18 16:30:44 UTC (rev 2903) @@ -93,6 +93,14 @@ */ CachedItemDescription*GetInventoryItem(int slot); + /// inline uint32 GetInventoryVersion() const + /// Info: Returns the cache version (PS#2691) + inline uint32 GetInventoryVersion() const { return version; } + + /// inline void SetInventoryVersion(uint32 ver) + /// Info: Sets the cache version (PS#2691) + inline void SetInventoryVersion(uint32 ver) { version = ver; } + private: csHash<CachedItemDescription*> itemhash; // all cached items in equip, bulk or containers @@ -100,6 +108,8 @@ // CachedItemDescription equipItems[INVENTORY_EQUIP_COUNT]; /// cached equip items csRef<MsgHandler> msgHandler; + + uint32 version; // Current cache version (PS#2691) }; #endif Modified: trunk/src/common/net/messages.cpp =================================================================== --- trunk/src/common/net/messages.cpp 2009-01-18 10:08:56 UTC (rev 2902) +++ trunk/src/common/net/messages.cpp 2009-01-18 16:30:44 UTC (rev 2903) @@ -2052,6 +2052,7 @@ if (command == UPDATE_LIST) totalEmptiedSlots = message->GetUInt32(); maxWeight = message->GetFloat(); + version = message->GetUInt32(); for ( size_t x = 0; x < totalItems; x++ ) { ItemDescription item; @@ -2090,10 +2091,11 @@ uint32_t totalItems, uint32_t totalEmptiedSlots, float maxWeight, + uint32_t cache_version, size_t msgsize) { // add on this header size - msg.AttachNew(new MsgEntry( msgsize + sizeof(uint8_t) + sizeof(uint32_t) * 2 + sizeof(float) )); + msg.AttachNew(new MsgEntry( msgsize + sizeof(uint8_t) + sizeof(uint32_t) * 3 + sizeof(float) )); msg->SetType(MSGTYPE_GUIINVENTORY); msg->clientnum = clientnum; @@ -2102,6 +2104,7 @@ if (command == UPDATE_LIST) msg->Add(totalEmptiedSlots); msg->Add( maxWeight ); + msg->Add( cache_version ); // Sets valid flag based on message overrun state valid=!(msg->overrun); @@ -2153,7 +2156,7 @@ msgtext.AppendFmt("Command: %d", command); if (command == LIST || command == UPDATE_LIST) { - msgtext.AppendFmt(" Total Items: %zu Max Weight: %.3f", totalItems, maxWeight); + msgtext.AppendFmt(" Total Items: %zu Max Weight: %.3f Cache Version: %d", totalItems, maxWeight, version); msgtext.AppendFmt(" List: "); for ( size_t x = 0; x < totalItems; x++ ) Modified: trunk/src/common/net/messages.h =================================================================== --- trunk/src/common/net/messages.h 2009-01-18 10:08:56 UTC (rev 2902) +++ trunk/src/common/net/messages.h 2009-01-18 16:30:44 UTC (rev 2903) @@ -43,7 +43,7 @@ // This holds the version number of the network code, remember to increase // this each time you do an update which breaks compatibility -#define PS_NETVERSION 0x0097 +#define PS_NETVERSION 0x0098 // Remember to bump the version in pscssetup.h, as well. // NPC Networking version is separate so we don't have to break compatibility @@ -1482,12 +1482,14 @@ * @param totalItems The total items or item stacks. * @param totalEmptiedSlots The total number of slots been emptied. * @param maxWeight The max weight the player can carry. + * @param cache_version Inventory cache version we're gonna build in this message. */ psGUIInventoryMessage( uint32_t clientnum, uint8_t command, uint32_t totalItems, uint32_t totalEmptiedSlots, float maxWeight, + uint32_t cache_version, size_t msgsize); @@ -1545,6 +1547,7 @@ size_t totalEmptiedSlots; float maxWeight; ///< The total max weight the player can carry. psMoney money; + uint32 version; /// cache version (PS#2691) }; //--------------------------------------------------------------------------- Modified: trunk/src/server/bulkobjects/pscharinventory.cpp =================================================================== --- trunk/src/server/bulkobjects/pscharinventory.cpp 2009-01-18 10:08:56 UTC (rev 2902) +++ trunk/src/server/bulkobjects/pscharinventory.cpp 2009-01-18 16:30:44 UTC (rev 2903) @@ -99,6 +99,7 @@ loaded = false; inExchangeMode = false; bEncumbranceLocked = false; + version = 1; // Client cache version initializes to 0. so, we start with 1 here } psCharacterInventory::~psCharacterInventory() Modified: trunk/src/server/bulkobjects/pscharinventory.h =================================================================== --- trunk/src/server/bulkobjects/pscharinventory.h 2009-01-18 10:08:56 UTC (rev 2902) +++ trunk/src/server/bulkobjects/pscharinventory.h 2009-01-18 16:30:44 UTC (rev 2903) @@ -131,6 +131,9 @@ /// Exchange mode flag bool inExchangeMode; + /// Inventory version + uint32 version; + public: psCharacterInventory(psCharacter *owner); @@ -182,6 +185,12 @@ /// @return The current capacity ( ie space ) of the inventory. float GetTotalSizeOfItemsInContainer(psItem *container=NULL); + /// @return The current inventory version. + uint32 GetInventoryVersion() const { return version; } + + /// Updates (increases) the current inventory version. + void IncreaseInventoryVersion() { version++; } + /** Put an item into the bulk inventory, and stack if needed. * @param item The item we want to place into the slot. * @param test Are we just testing if we can put this into the slot Modified: trunk/src/server/psserverchar.cpp =================================================================== --- trunk/src/server/psserverchar.cpp 2009-01-18 10:08:56 UTC (rev 2902) +++ trunk/src/server/psserverchar.cpp 2009-01-18 16:30:44 UTC (rev 2903) @@ -417,12 +417,15 @@ if (exchange) m += -exchange->GetOfferedMoney(client); msgsize += strlen(m.ToString()) + 1; + + msgsize += sizeof(uint32); // apply version size // actually create the message outgoing = new psGUIInventoryMessage(toClientNumber, psGUIInventoryMessage::LIST, (uint32_t)chardata->Inventory().GetInventoryIndexCount()-1, // skip item 0 - (uint32_t)0, chardata->Inventory().MaxWeight(), msgsize); + (uint32_t)0, chardata->Inventory().MaxWeight(), + chardata->Inventory().GetInventoryVersion(), msgsize); for (size_t i=1; i < chardata->Inventory().GetInventoryIndexCount(); i++) { @@ -455,6 +458,9 @@ outgoing->msg->ClipToCurrentSize(); psserver->GetEventManager()->SendMessage(outgoing->msg); + // Increase the inventory version, since this version was sent. + chardata->Inventory().IncreaseInventoryVersion(); + // server now can believe the clients inventory cache is upto date // inventoryCache->SetCacheStatus(psCache::VALID); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ven...@us...> - 2009-01-18 21:19:13
|
Revision: 2905 http://planeshift.svn.sourceforge.net/planeshift/?rev=2905&view=rev Author: Vengeance2001 Date: 2009-01-18 21:19:09 +0000 (Sun, 18 Jan 2009) Log Message: ----------- Renamed iPAWSDrawable and restructured that a little bit to lay the groundwork for future PAWS extensions. Modified Paths: -------------- trunk/src/client/gui/pawscharcreatemain.cpp trunk/src/client/gui/pawscharcreatemain.h trunk/src/client/gui/pawsgameboard.cpp trunk/src/client/gui/pawsgameboard.h trunk/src/client/gui/pawsilluminationwindow.cpp trunk/src/client/gui/pawsilluminationwindow.h trunk/src/client/gui/pawsslot.cpp trunk/src/client/gui/pawsslot.h trunk/src/common/paws/pawsborder.cpp trunk/src/common/paws/pawsborder.h trunk/src/common/paws/pawsbutton.cpp trunk/src/common/paws/pawsbutton.h trunk/src/common/paws/pawsframedrawable.cpp trunk/src/common/paws/pawsframedrawable.h trunk/src/common/paws/pawsimagedrawable.h trunk/src/common/paws/pawslistbox.cpp trunk/src/common/paws/pawsmanager.cpp trunk/src/common/paws/pawsmanager.h trunk/src/common/paws/pawsmenu.cpp trunk/src/common/paws/pawsmenu.h trunk/src/common/paws/pawsmouse.cpp trunk/src/common/paws/pawsmouse.h trunk/src/common/paws/pawsprefmanager.cpp trunk/src/common/paws/pawstexturemanager.cpp trunk/src/common/paws/pawstexturemanager.h trunk/src/common/paws/pawstree.cpp trunk/src/common/paws/pawstree.h trunk/src/common/paws/pawswidget.cpp trunk/src/common/paws/pawswidget.h trunk/src/pslaunch/pawslauncherwindow.cpp trunk/src/tools/pawseditor/pawseditorapp.cpp trunk/src/tools/pawseditor/peskinselector.cpp Modified: trunk/src/client/gui/pawscharcreatemain.cpp =================================================================== --- trunk/src/client/gui/pawscharcreatemain.cpp 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/client/gui/pawscharcreatemain.cpp 2009-01-18 21:19:09 UTC (rev 2905) @@ -74,12 +74,12 @@ currentGender = PSCHARACTER_GENDER_MALE; lastGender = -1; - femaleImage = PawsManager::GetSingleton().GetTextureManager()->GetDrawable(FEMALE_ICON); + femaleImage = PawsManager::GetSingleton().GetTextureManager()->GetPawsImage(FEMALE_ICON); if (!femaleImage) { Warning1( LOG_PAWS, "Could not locate the female icon image. This image is not part of the GPL."); } - neutralImage = PawsManager::GetSingleton().GetTextureManager()->GetDrawable(NEUTRAL_ICON); + neutralImage = PawsManager::GetSingleton().GetTextureManager()->GetPawsImage(NEUTRAL_ICON); if (!neutralImage) { Warning1( LOG_PAWS, "Could not locate the neutral icon image. This image is not part of the GPL."); Modified: trunk/src/client/gui/pawscharcreatemain.h =================================================================== --- trunk/src/client/gui/pawscharcreatemain.h 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/client/gui/pawscharcreatemain.h 2009-01-18 21:19:09 UTC (rev 2905) @@ -132,8 +132,8 @@ /// For outgoing messages. csRef<MsgHandler> msgHandler; - csRef<iPAWSDrawable> femaleImage; - csRef<iPAWSDrawable> neutralImage; + csRef<iPawsImage> femaleImage; + csRef<iPawsImage> neutralImage; /// Paper doll view of model. Modified: trunk/src/client/gui/pawsgameboard.cpp =================================================================== --- trunk/src/client/gui/pawsgameboard.cpp 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/client/gui/pawsgameboard.cpp 2009-01-18 21:19:09 UTC (rev 2905) @@ -660,7 +660,7 @@ return; } - image = PawsManager::GetSingleton().GetTextureManager()->GetDrawable(art); + image = PawsManager::GetSingleton().GetTextureManager()->GetPawsImage(art); if (!image) { Error2("Could not create image \"%s\"", art.GetData()); Modified: trunk/src/client/gui/pawsgameboard.h =================================================================== --- trunk/src/client/gui/pawsgameboard.h 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/client/gui/pawsgameboard.h 2009-01-18 21:19:09 UTC (rev 2905) @@ -90,7 +90,7 @@ uint8_t oldState; /// The game piece image. - csRef<iPAWSDrawable> image; + csRef<iPawsImage> image; }; Modified: trunk/src/client/gui/pawsilluminationwindow.cpp =================================================================== --- trunk/src/client/gui/pawsilluminationwindow.cpp 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/client/gui/pawsilluminationwindow.cpp 2009-01-18 21:19:09 UTC (rev 2905) @@ -180,7 +180,7 @@ SetTitle(sketchName); if (!blackBox) - blackBox = PawsManager::GetSingleton().GetTextureManager()->GetDrawable("blackbox"); + blackBox = PawsManager::GetSingleton().GetTextureManager()->GetPawsImage("blackbox"); Show(); } @@ -965,7 +965,7 @@ y = _y; str = icon; - iconImage = PawsManager::GetSingleton().GetTextureManager()->GetDrawable(str); + iconImage = PawsManager::GetSingleton().GetTextureManager()->GetPawsImage(str); // printf("Icon %s at (%d,%d)\n",str.GetDataSafe(),x,y); if (parent) Modified: trunk/src/client/gui/pawsilluminationwindow.h =================================================================== --- trunk/src/client/gui/pawsilluminationwindow.h 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/client/gui/pawsilluminationwindow.h 2009-01-18 21:19:09 UTC (rev 2905) @@ -80,7 +80,7 @@ }; struct SketchIcon : public SketchObject { - csRef<iPAWSDrawable> iconImage; + csRef<iPawsImage> iconImage; SketchIcon() : SketchObject() {} SketchIcon(int _x, int _y, const char *icon, pawsSketchWindow *parent); virtual ~SketchIcon() {}; @@ -191,7 +191,7 @@ size_t selectedIndex; int dirty; uint32_t currentItemID; - csRef<iPAWSDrawable> blackBox; + csRef<iPawsImage> blackBox; bool editMode; bool mouseDown; int mouseDownX; // used to calculate the updatePosition diff. this value is updated OnMouseDown Modified: trunk/src/client/gui/pawsslot.cpp =================================================================== --- trunk/src/client/gui/pawsslot.cpp 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/client/gui/pawsslot.cpp 2009-01-18 21:19:09 UTC (rev 2905) @@ -151,7 +151,7 @@ { empty = false; - image = PawsManager::GetSingleton().GetTextureManager()->GetDrawable(imageName); + image = PawsManager::GetSingleton().GetTextureManager()->GetPawsImage(imageName); if (drawStackCount) stackCountLabel->Show(); Modified: trunk/src/client/gui/pawsslot.h =================================================================== --- trunk/src/client/gui/pawsslot.h 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/client/gui/pawsslot.h 2009-01-18 21:19:09 UTC (rev 2905) @@ -29,7 +29,7 @@ void SetPurifyStatus(int status); void PlaceItem( const char* imageName, int count = 0 ); - csRef<iPAWSDrawable> Image() { return image;} + csRef<iPawsImage> Image() { return image;} const char *ImageName(); const csString & SlotName() const { return slotName; } @@ -64,7 +64,7 @@ bool drawStackCount; bool reserved; // implemented to fix dequip behaviour. Cleared on PlaceItem and Clear - csRef<iPAWSDrawable> image; + csRef<iPawsImage> image; pawsWidget* purifySign; pawsTextBox* stackCountLabel; bool handleMouseClicks; Modified: trunk/src/common/paws/pawsborder.cpp =================================================================== --- trunk/src/common/paws/pawsborder.cpp 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/common/paws/pawsborder.cpp 2009-01-18 21:19:09 UTC (rev 2905) @@ -50,7 +50,7 @@ // border definition. for ( int x = 0; x < PAWS_BORDER_MAX; x++ ) { - borderImages[x] = PawsManager::GetSingleton().GetTextureManager()->GetDrawable(def->descriptions[x]); + borderImages[x] = PawsManager::GetSingleton().GetTextureManager()->GetPawsImage(def->descriptions[x]); if (!borderImages[x]) { Warning2(LOG_PAWS, "Could not retrieve border drawable: >%s<", def->descriptions[x].GetData()); Modified: trunk/src/common/paws/pawsborder.h =================================================================== --- trunk/src/common/paws/pawsborder.h 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/common/paws/pawsborder.h 2009-01-18 21:19:09 UTC (rev 2905) @@ -95,10 +95,10 @@ csRect GetRect(); void SetTitle(const char *t, bool shadow = true); - void SetTitleImage(csRef<iPAWSDrawable> drawable) { titleImage = drawable; } // This will take delete responsibility + void SetTitleImage(csRef<iPawsImage> drawable) { titleImage = drawable; } // This will take delete responsibility void SetTitleAlign(int al) { align = al; } - csRef<iPAWSDrawable> GetTitleImage() { return titleImage; } + csRef<iPawsImage> GetTitleImage() { return titleImage; } const char* GetTitle() { return title; } protected: @@ -109,12 +109,12 @@ csRect frame; pawsWidget* parent; - csRef<iPAWSDrawable> borderImages[PAWS_BORDER_MAX]; + csRef<iPawsImage> borderImages[PAWS_BORDER_MAX]; /// Title bar text csString title; /// Title bar image - csRef<iPAWSDrawable> titleImage; + csRef<iPawsImage> titleImage; /// Alignment of title text int align; Modified: trunk/src/common/paws/pawsbutton.cpp =================================================================== --- trunk/src/common/paws/pawsbutton.cpp 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/common/paws/pawsbutton.cpp 2009-01-18 21:19:09 UTC (rev 2905) @@ -160,27 +160,27 @@ void pawsButton::SetDownImage(const csString & image) { - pressedImage = PawsManager::GetSingleton().GetTextureManager()->GetDrawable(image); + pressedImage = PawsManager::GetSingleton().GetTextureManager()->GetPawsImage(image); } void pawsButton::SetUpImage(const csString & image) { - releasedImage = PawsManager::GetSingleton().GetTextureManager()->GetDrawable(image); + releasedImage = PawsManager::GetSingleton().GetTextureManager()->GetPawsImage(image); } void pawsButton::SetGreyUpImage(const char * greyUpImage) { - this->greyUpImage = PawsManager::GetSingleton().GetTextureManager()->GetDrawable(greyUpImage); + this->greyUpImage = PawsManager::GetSingleton().GetTextureManager()->GetPawsImage(greyUpImage); } void pawsButton::SetGreyDownImage(const char * greyDownImage) { - this->greyDownImage = PawsManager::GetSingleton().GetTextureManager()->GetDrawable(greyDownImage); + this->greyDownImage = PawsManager::GetSingleton().GetTextureManager()->GetPawsImage(greyDownImage); } void pawsButton::SetOnSpecialImage( const csString & image ) { - specialFlashImage = PawsManager::GetSingleton().GetTextureManager()->GetDrawable(image); + specialFlashImage = PawsManager::GetSingleton().GetTextureManager()->GetPawsImage(image); } Modified: trunk/src/common/paws/pawsbutton.h =================================================================== --- trunk/src/common/paws/pawsbutton.h 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/common/paws/pawsbutton.h 2009-01-18 21:19:09 UTC (rev 2905) @@ -96,16 +96,16 @@ bool down; /// Image to draw when button is pressed or when the mouse enters. - csRef<iPAWSDrawable> pressedImage; + csRef<iPawsImage> pressedImage; /// Image to draw when button is released or when the mouse exits. - csRef<iPAWSDrawable> releasedImage; + csRef<iPawsImage> releasedImage; - csRef<iPAWSDrawable> greyUpImage; - csRef<iPAWSDrawable> greyDownImage; + csRef<iPawsImage> greyUpImage; + csRef<iPawsImage> greyDownImage; /// Image to draw when button is released. - csRef<iPAWSDrawable> specialFlashImage; + csRef<iPawsImage> specialFlashImage; /// Check to see if this is a toggle button. bool toggle; Modified: trunk/src/common/paws/pawsframedrawable.cpp =================================================================== --- trunk/src/common/paws/pawsframedrawable.cpp 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/common/paws/pawsframedrawable.cpp 2009-01-18 21:19:09 UTC (rev 2905) @@ -48,7 +48,7 @@ } pawsFrameDrawable::pawsFrameDrawable(csRef<iDocumentNode> node) -: scfImplementationType (this) + : scfImplementationType (this) { defaultTransparentColourBlue = -1; defaultTransparentColourGreen = -1; @@ -216,3 +216,37 @@ { return defaultAlphaValue; } + +void pawsFrameDrawable::DrawPiece( FRAME_DRAWABLE_PIECE p, int x, int y, int w, int h, int alpha, bool scaleX/*=false*/, bool scaleY/*=false*/ ) +{ + if (!pieces[p].drawable) + return; + + if (scaleX) // if this piece has been scaled along the x-axis then we want the offset to extend both sides + { + x -= pieces[p].offsetx; + w += pieces[p].offsetx*2; + } + else + x += pieces[p].offsetx; + + if (scaleY) // if this piece has been scaled along the y-axis then we want the offset to extend both sides + { + y -= pieces[p].offsety; + h += pieces[p].offsety*2; + } + else + y += pieces[p].offsety; + + pieces[p].drawable->Draw(x, y, w, h, alpha); +} + +void pawsFrameDrawable::DrawPiece( FRAME_DRAWABLE_PIECE p, int x, int y, int alpha ) +{ + if (!pieces[p].drawable) + return; + + x += pieces[p].offsetx; + y += pieces[p].offsety; + pieces[p].drawable->Draw(x, y, alpha); +} \ No newline at end of file Modified: trunk/src/common/paws/pawsframedrawable.h =================================================================== --- trunk/src/common/paws/pawsframedrawable.h 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/common/paws/pawsframedrawable.h 2009-01-18 21:19:09 UTC (rev 2905) @@ -22,7 +22,7 @@ #include "pawstexturemanager.h" -class pawsFrameDrawable : public scfImplementation1<pawsFrameDrawable, iPAWSDrawable> +class pawsFrameDrawable : public scfImplementation1<pawsFrameDrawable, iPawsImage> { private: enum FRAME_DRAWABLE_PIECE @@ -39,9 +39,10 @@ FDP_COUNT }; + struct pawsFrameDrawablePiece { - csRef<iPAWSDrawable> drawable; + csRef<iPawsImage> drawable; int offsetx; int offsety; }; @@ -72,39 +73,9 @@ int defaultTransparentColourBlue; void LoadPiece(csRef<iDocumentNode> node, FRAME_DRAWABLE_PIECE piece); - inline void DrawPiece(FRAME_DRAWABLE_PIECE p, int x, int y, int w, int h, int alpha, bool scaleX=false, bool scaleY=false) - { - if (!pieces[p].drawable) - return; + void DrawPiece(FRAME_DRAWABLE_PIECE p, int x, int y, int w, int h, int alpha, bool scaleX=false, bool scaleY=false); + void DrawPiece(FRAME_DRAWABLE_PIECE p, int x, int y, int alpha); - if (scaleX) // if this piece has been scaled along the x-axis then we want the offset to extend both sides - { - x -= pieces[p].offsetx; - w += pieces[p].offsetx*2; - } - else - x += pieces[p].offsetx; - - if (scaleY) // if this piece has been scaled along the y-axis then we want the offset to extend both sides - { - y -= pieces[p].offsety; - h += pieces[p].offsety*2; - } - else - y += pieces[p].offsety; - - pieces[p].drawable->Draw(x, y, w, h, alpha); - } - inline void DrawPiece(FRAME_DRAWABLE_PIECE p, int x, int y, int alpha) - { - if (!pieces[p].drawable) - return; - - x += pieces[p].offsetx; - y += pieces[p].offsety; - pieces[p].drawable->Draw(x, y, alpha); - } - public: pawsFrameDrawable(csRef<iDocumentNode> node); Modified: trunk/src/common/paws/pawsimagedrawable.h =================================================================== --- trunk/src/common/paws/pawsimagedrawable.h 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/common/paws/pawsimagedrawable.h 2009-01-18 21:19:09 UTC (rev 2905) @@ -22,7 +22,7 @@ #include "pawstexturemanager.h" -class pawsImageDrawable : public scfImplementation1<pawsImageDrawable, iPAWSDrawable> +class pawsImageDrawable : public scfImplementation1<pawsImageDrawable, iPawsImage> { private: /// The VFS path to the file. Modified: trunk/src/common/paws/pawslistbox.cpp =================================================================== --- trunk/src/common/paws/pawslistbox.cpp 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/common/paws/pawslistbox.cpp 2009-01-18 21:19:09 UTC (rev 2905) @@ -1020,7 +1020,7 @@ { rows[i] = sortedRows[i]; if(sortedRows[i] == selectedrow) //check if the current row is the one which was selected - selected = i; //if so update our selected variable + selected = (int) i; //if so update our selected variable } delete [] sortedRows; Modified: trunk/src/common/paws/pawsmanager.cpp =================================================================== --- trunk/src/common/paws/pawsmanager.cpp 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/common/paws/pawsmanager.cpp 2009-01-18 21:19:09 UTC (rev 2905) @@ -161,7 +161,7 @@ mouse = new pawsMouse(); mouse->ChangeImage("Standard Mouse Pointer"); - resizeImg = textureManager->GetDrawable("ResizeBox"); + resizeImg = textureManager->GetPawsImage("ResizeBox"); graphics2D->SetMouseCursor( csmcNone ); Modified: trunk/src/common/paws/pawsmanager.h =================================================================== --- trunk/src/common/paws/pawsmanager.h 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/common/paws/pawsmanager.h 2009-01-18 21:19:09 UTC (rev 2905) @@ -202,7 +202,7 @@ pawsMouse* GetMouse() { return mouse; } /// Returns the resized image. - csRef<iPAWSDrawable> GetResizeImage() { return resizeImg; } + csRef<iPawsImage> GetResizeImage() { return resizeImg; } /** Locate a widget by name. * @param name The name of the widget. @@ -485,7 +485,7 @@ pawsMouse* mouse; /// Resized image. - csRef<iPAWSDrawable> resizeImg; + csRef<iPawsImage> resizeImg; /// An array of pointers to available factories. csPDelArray<pawsWidgetFactory> factories; Modified: trunk/src/common/paws/pawsmenu.cpp =================================================================== --- trunk/src/common/paws/pawsmenu.cpp 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/common/paws/pawsmenu.cpp 2009-01-18 21:19:09 UTC (rev 2905) @@ -447,7 +447,7 @@ csRef<iDocumentAttribute> attr; csString colourStr; - arrowImage = PawsManager::GetSingleton().GetTextureManager()->GetDrawable("Right Arrow"); + arrowImage = PawsManager::GetSingleton().GetTextureManager()->GetPawsImage("Right Arrow"); if (!arrowImage) return false; Modified: trunk/src/common/paws/pawsmenu.h =================================================================== --- trunk/src/common/paws/pawsmenu.h 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/common/paws/pawsmenu.h 2009-01-18 21:19:09 UTC (rev 2905) @@ -284,7 +284,7 @@ pawsButton * stickyButton, * closeButton; pawsTextBox * label; - csRef<iPAWSDrawable> arrowImage; // image of right arrow indicating that menu item invokes a submenu + csRef<iPawsImage> arrowImage; // image of right arrow indicating that menu item invokes a submenu pawsMenuAlign align; Modified: trunk/src/common/paws/pawsmouse.cpp =================================================================== --- trunk/src/common/paws/pawsmouse.cpp 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/common/paws/pawsmouse.cpp 2009-01-18 21:19:09 UTC (rev 2905) @@ -47,7 +47,7 @@ deltas = psPoint( 0, 0 ); hidden = false; crosshair = false; - crosshairImage = PawsManager::GetSingleton().GetTextureManager()->GetDrawable("Crosshair Mouse Pointer"); + crosshairImage = PawsManager::GetSingleton().GetTextureManager()->GetPawsImage("Crosshair Mouse Pointer"); useOS = false; } @@ -66,20 +66,20 @@ void pawsMouse::ChangeImage( const char* imageName ) { - cursorImage = PawsManager::GetSingleton().GetTextureManager()->GetDrawable(imageName); + cursorImage = PawsManager::GetSingleton().GetTextureManager()->GetPawsImage(imageName); SetOSMouse(cursorImage); } -void pawsMouse::ChangeImage(csRef<iPAWSDrawable> drawable) +void pawsMouse::ChangeImage(csRef<iPawsImage> drawable) { cursorImage = drawable; SetOSMouse(cursorImage); } -void pawsMouse::SetOSMouse(csRef<iPAWSDrawable> drawable) +void pawsMouse::SetOSMouse(csRef<iPawsImage> drawable) { #ifdef CS_PLATFORM_WIN32 - pawsImageDrawable * pwDraw = dynamic_cast<pawsImageDrawable *>((iPAWSDrawable *)drawable); + pawsImageDrawable * pwDraw = dynamic_cast<pawsImageDrawable *>((iPawsImage *)drawable); if (!pwDraw) return; Modified: trunk/src/common/paws/pawsmouse.h =================================================================== --- trunk/src/common/paws/pawsmouse.h 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/common/paws/pawsmouse.h 2009-01-18 21:19:09 UTC (rev 2905) @@ -54,7 +54,7 @@ * @param imageName A resource name to use as the image. */ void ChangeImage( const char* imageName ); - void ChangeImage(csRef<iPAWSDrawable> drawable); + void ChangeImage(csRef<iPawsImage> drawable); void Draw(); void Hide(bool h = true); void WantCrosshair(bool h = true) { crosshair = h; } @@ -86,8 +86,8 @@ psPoint currentPosition; psPoint deltas; - csRef<iPAWSDrawable> cursorImage; - csRef<iPAWSDrawable> crosshairImage; + csRef<iPawsImage> cursorImage; + csRef<iPawsImage> crosshairImage; bool hidden, crosshair; bool useOS; @@ -98,7 +98,7 @@ csRef<iImage> image; - void SetOSMouse(csRef<iPAWSDrawable> mouseImage); + void SetOSMouse(csRef<iPawsImage> mouseImage); }; #endif Modified: trunk/src/common/paws/pawsprefmanager.cpp =================================================================== --- trunk/src/common/paws/pawsprefmanager.cpp 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/common/paws/pawsprefmanager.cpp 2009-01-18 21:19:09 UTC (rev 2905) @@ -189,9 +189,9 @@ Error2("Missing <image> tag in %s", file); return false; } - csRef<iPAWSDrawable> drawable; + csRef<iPawsImage> drawable; drawable.AttachNew(new pawsImageDrawable(image)); - PawsManager::GetSingleton().GetTextureManager()->AddDrawable(drawable); + PawsManager::GetSingleton().GetTextureManager()->AddPawsImage(drawable); definition->descriptions[current] = image->GetAttributeValue("resource"); Modified: trunk/src/common/paws/pawstexturemanager.cpp =================================================================== --- trunk/src/common/paws/pawstexturemanager.cpp 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/common/paws/pawstexturemanager.cpp 2009-01-18 21:19:09 UTC (rev 2905) @@ -53,8 +53,8 @@ } pawsTextureManager::~pawsTextureManager() - { - } +{ +} bool pawsTextureManager::LoadImageList( const char* listName ) { @@ -90,39 +90,40 @@ csRef<iDocumentNodeIterator> iter = topNode->GetNodes(); while ( iter->HasNext() ) -{ + { csRef<iDocumentNode> node = iter->Next(); if ( node->GetType() != CS_NODE_ELEMENT ) continue; - if (loadedDrawables.Contains(node->GetAttributeValue("resource"))) + if (elementList.Contains(node->GetAttributeValue("resource"))) continue; - csRef<iPAWSDrawable> drawable; + iPawsImage *element = NULL; if (!strcmp(node->GetValue(), "image")) - drawable.AttachNew(new pawsImageDrawable(node)); + element = new pawsImageDrawable(node); else if (!strcmp(node->GetValue(), "frame")) - drawable.AttachNew(new pawsFrameDrawable(node)); - if (drawable) - loadedDrawables.Put(drawable->GetName(), drawable); - } + element = new pawsFrameDrawable(node); + + if (element) + elementList.Put(element->GetName(), element); + } return true; - } +} void pawsTextureManager::Remove( const char* resource ) - { - loadedDrawables.DeleteAll(resource); - } +{ + elementList.DeleteAll(resource); +} -csRef<iPAWSDrawable> pawsTextureManager::GetDrawable(const char * name) - { - return loadedDrawables.Get(name, 0); - } +csPtr<iPawsImage> pawsTextureManager::GetPawsImage(const char * name) +{ + return csPtr<iPawsImage>(elementList.Get(name, 0)); +} -void pawsTextureManager::AddDrawable(csRef<iPAWSDrawable> drawable) - { - loadedDrawables.Put(drawable->GetName(), drawable); +void pawsTextureManager::AddPawsImage(iPawsImage * element) +{ + elementList.Put(element->GetName(), element); } Modified: trunk/src/common/paws/pawstexturemanager.h =================================================================== --- trunk/src/common/paws/pawstexturemanager.h 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/common/paws/pawstexturemanager.h 2009-01-18 21:19:09 UTC (rev 2905) @@ -37,9 +37,9 @@ class pawsTextureManager; -struct iPAWSDrawable : public virtual iBase +struct iPawsImage : public virtual iBase { - SCF_INTERFACE(iPAWSDrawable, 1, 0, 0); + SCF_INTERFACE(iPawsImage, 1, 0, 0); virtual const char * GetName() const = 0; virtual void Draw(int x, int y, int alpha=-1) = 0; @@ -81,8 +81,8 @@ */ void Remove( const char* name ); - csRef<iPAWSDrawable> GetDrawable(const char * name); - void AddDrawable(csRef<iPAWSDrawable> drawable); + csPtr<iPawsImage> GetPawsImage(const char *name); + void AddPawsImage(iPawsImage *element); public: iObjectRegistry* objectReg; @@ -90,7 +90,7 @@ csRef<iVFS> vfs; csRef<iDocumentSystem> xml; - csHash<csRef<iPAWSDrawable>, csString> loadedDrawables; + csHash<csRef<iPawsImage>, csString> elementList; }; #endif Modified: trunk/src/common/paws/pawstree.cpp =================================================================== --- trunk/src/common/paws/pawstree.cpp 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/common/paws/pawstree.cpp 2009-01-18 21:19:09 UTC (rev 2905) @@ -760,8 +760,8 @@ lineColor = _lineColor; collSpacing = _collSpacing; - collImage = PawsManager::GetSingleton().GetTextureManager()->GetDrawable("treecollapse"); - expandImage = PawsManager::GetSingleton().GetTextureManager()->GetDrawable("treeexpand"); + collImage = PawsManager::GetSingleton().GetTextureManager()->GetPawsImage("treecollapse"); + expandImage = PawsManager::GetSingleton().GetTextureManager()->GetPawsImage("treeexpand"); } pawsStdTreeDecorator::~pawsStdTreeDecorator() @@ -779,7 +779,7 @@ void pawsStdTreeDecorator::DecorateSubtree(pawsTreeNode * node) { - csRef<iPAWSDrawable> currImage; + csRef<iPawsImage> currImage; pawsTreeNode * child; csRect nodeFrame, childFrame, collSignFrame; int vertLineX, vertLineYMin, vertLineYMax; Modified: trunk/src/common/paws/pawstree.h =================================================================== --- trunk/src/common/paws/pawstree.h 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/common/paws/pawstree.h 2009-01-18 21:19:09 UTC (rev 2905) @@ -348,8 +348,8 @@ int lineColor; // color of lines int collSpacing; // distance between node and expand/collapse sign - csRef<iPAWSDrawable> collImage; - csRef<iPAWSDrawable> expandImage; + csRef<iPawsImage> collImage; + csRef<iPawsImage> expandImage; }; Modified: trunk/src/common/paws/pawswidget.cpp =================================================================== --- trunk/src/common/paws/pawswidget.cpp 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/common/paws/pawswidget.cpp 2009-01-18 21:19:09 UTC (rev 2905) @@ -548,7 +548,7 @@ if ( bgImageNode ) { csString image = bgImageNode->GetAttributeValue("resource"); - bgImage = PawsManager::GetSingleton().GetTextureManager()->GetDrawable(image); + bgImage = PawsManager::GetSingleton().GetTextureManager()->GetPawsImage(image); if(!bgImage) { Warning2(LOG_PAWS, "GUI image '%s' not found.\n", image.GetData()); @@ -903,7 +903,7 @@ void pawsWidget::SetBackground( const char* image ) { - bgImage = PawsManager::GetSingleton().GetTextureManager()->GetDrawable(image); + bgImage = PawsManager::GetSingleton().GetTextureManager()->GetPawsImage(image); if (!bgImage) { @@ -1046,7 +1046,7 @@ if ( IsResizable() && showResize ) { - csRef<iPAWSDrawable> resize = PawsManager::GetSingleton().GetResizeImage(); + csRef<iPawsImage> resize = PawsManager::GetSingleton().GetResizeImage(); if (resize) resize->Draw( ScreenFrame().xmax-8, ScreenFrame().ymax-8,8,8 ); } @@ -2575,7 +2575,7 @@ { borderTitleShadow = shadowTitle; border->SetTitle( text, borderTitleShadow ); - csRef<iPAWSDrawable> titleImage = PawsManager::GetSingleton().GetTextureManager()->GetDrawable(image); + csRef<iPawsImage> titleImage = PawsManager::GetSingleton().GetTextureManager()->GetPawsImage(image); border->SetTitleImage(titleImage); int alignValue = ALIGN_LEFT; @@ -2631,7 +2631,7 @@ void pawsWidget::SetMaskingImage(const char* image) { - maskImage = PawsManager::GetSingleton().GetTextureManager()->GetDrawable(image); + maskImage = PawsManager::GetSingleton().GetTextureManager()->GetPawsImage(image); if (!maskImage) { Warning3( LOG_PAWS, "Could not locate masking image %s for widget %s",image,GetName()); Modified: trunk/src/common/paws/pawswidget.h =================================================================== --- trunk/src/common/paws/pawswidget.h 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/common/paws/pawswidget.h 2009-01-18 21:19:09 UTC (rev 2905) @@ -94,7 +94,7 @@ PW_SCRIPT_EVENT_COUNT }; -struct iPAWSDrawable; +struct iPawsImage; class PawsManager; class pawsBorder; class pawsScrollBar; @@ -217,7 +217,7 @@ int bgColour; /// Background image. - csRef<iPAWSDrawable> bgImage; + csRef<iPawsImage> bgImage; /// border created by GetBorder(). pawsBorder* border; @@ -302,7 +302,7 @@ csString defaultToolTip; /// Masking image, used for nice-looking stuff. - csRef<iPAWSDrawable> maskImage; + csRef<iPawsImage> maskImage; /** Flag determines if WidgetAT() ignores this widget. * @remark Default is FALSE. Set during LoadAttributes(). Modified: trunk/src/pslaunch/pawslauncherwindow.cpp =================================================================== --- trunk/src/pslaunch/pawslauncherwindow.cpp 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/pslaunch/pawslauncherwindow.cpp 2009-01-18 21:19:09 UTC (rev 2905) @@ -1000,9 +1000,9 @@ return false; } - csRef<iPAWSDrawable> img; + csRef<iPawsImage> img; img.AttachNew(new pawsImageDrawable(filename.GetData(), resname, false, csRect(), 0, 0, 0, 0)); - PawsManager::GetSingleton().GetTextureManager()->AddDrawable(img); + PawsManager::GetSingleton().GetTextureManager()->AddPawsImage(img); return true; } Modified: trunk/src/tools/pawseditor/pawseditorapp.cpp =================================================================== --- trunk/src/tools/pawseditor/pawseditorapp.cpp 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/tools/pawseditor/pawseditorapp.cpp 2009-01-18 21:19:09 UTC (rev 2905) @@ -382,10 +382,10 @@ // Compile the structure - csRef<iPAWSDrawable> drawable; + csRef<iPawsImage> drawable; if (!strcmp(node->GetValue(), "image")) { - paws->GetTextureManager()->AddDrawable(new pawsImageDrawable(node)); + paws->GetTextureManager()->AddPawsImage(new pawsImageDrawable(node)); } } Modified: trunk/src/tools/pawseditor/peskinselector.cpp =================================================================== --- trunk/src/tools/pawseditor/peskinselector.cpp 2009-01-18 16:33:27 UTC (rev 2904) +++ trunk/src/tools/pawseditor/peskinselector.cpp 2009-01-18 21:19:09 UTC (rev 2905) @@ -302,9 +302,9 @@ return false; } - csRef<iPAWSDrawable> img; + csRef<iPawsImage> img; img.AttachNew(new pawsImageDrawable(filename.GetData(), resname, false, csRect(), 0, 0, 0, 0)); - PawsManager::GetSingleton().GetTextureManager()->AddDrawable(img); + PawsManager::GetSingleton().GetTextureManager()->AddPawsImage(img); return true; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wel...@us...> - 2009-01-24 06:53:19
|
Revision: 2945 http://planeshift.svn.sourceforge.net/planeshift/?rev=2945&view=rev Author: weltall2 Date: 2009-01-24 06:53:09 +0000 (Sat, 24 Jan 2009) Log Message: ----------- Code reordering in gem and cmusers by kougaro Modified Paths: -------------- trunk/src/client/cmdusers.cpp trunk/src/server/gem.cpp Modified: trunk/src/client/cmdusers.cpp =================================================================== --- trunk/src/client/cmdusers.cpp 2009-01-22 22:48:11 UTC (rev 2944) +++ trunk/src/client/cmdusers.cpp 2009-01-24 06:53:09 UTC (rev 2945) @@ -64,126 +64,128 @@ { // msgqueue->Subscribe(MSGTYPE_CHAT,this); - cmdsource->Subscribe("/who",this); // list players on server + cmdsource->Subscribe("/admin", this); + cmdsource->Subscribe("/advice", this); + cmdsource->Subscribe("/advisor", this); + cmdsource->Subscribe("/assist", this); + cmdsource->Subscribe("/attack",this); + cmdsource->Subscribe("/away", this); + cmdsource->Subscribe("/bank", this); cmdsource->Subscribe("/buddy",this); // add named player to buddy list - cmdsource->Subscribe("/roll",this); - cmdsource->Subscribe("/pos",this); - //cmdsource->Subscribe("/spawn",this); - cmdsource->Subscribe("/unstick",this); - cmdsource->Subscribe("/attack",this); - cmdsource->Subscribe("/stopattack",this); - cmdsource->Subscribe("/admin", this); - cmdsource->Subscribe("/stoptrading", this); - cmdsource->Subscribe("/starttrading", this); cmdsource->Subscribe("/buy", this); - cmdsource->Subscribe("/sell", this); - cmdsource->Subscribe("/trade",this); + cmdsource->Subscribe("/cast", this); + cmdsource->Subscribe("/challenge", this); + cmdsource->Subscribe("/clear", this); + cmdsource->Subscribe("/combine", this); + cmdsource->Subscribe("/dequip", this); + cmdsource->Subscribe("/die", this); + cmdsource->Subscribe("/dig", this); + cmdsource->Subscribe("/drop", this); + cmdsource->Subscribe("/emote", this); + cmdsource->Subscribe("/equip", this); + cmdsource->Subscribe("/fish", this); + cmdsource->Subscribe("/game", this); cmdsource->Subscribe("/give",this); cmdsource->Subscribe("/guard",this); - cmdsource->Subscribe("/assist", this); + cmdsource->Subscribe("/help", this); cmdsource->Subscribe("/ignore", this); - cmdsource->Subscribe("/cast", this); - cmdsource->Subscribe("/away", this); + cmdsource->Subscribe("/introduce", this); cmdsource->Subscribe("/loot", this); - cmdsource->Subscribe("/clear", this); - cmdsource->Subscribe("/advisor", this); - cmdsource->Subscribe("/help", this); - cmdsource->Subscribe("/advice", this); - cmdsource->Subscribe("/train", this); + cmdsource->Subscribe("/marriage", this); + cmdsource->Subscribe("/motd", this); + cmdsource->Subscribe("/npcmenu", this); + cmdsource->Subscribe("/pet", this); + cmdsource->Subscribe("/picklock",this); + cmdsource->Subscribe("/pickup", this); + cmdsource->Subscribe("/pos",this); //cmdsource->Subscribe("/quests", this); - cmdsource->Subscribe("/use", this); - cmdsource->Subscribe("/dig", this); - cmdsource->Subscribe("/fish", this); + cmdsource->Subscribe("/repair", this); + cmdsource->Subscribe("/roll",this); + cmdsource->Subscribe("/rotate",this); + cmdsource->Subscribe("/sell", this); + cmdsource->Subscribe("/show", this); + cmdsource->Subscribe("/sit", this); + //cmdsource->Subscribe("/spawn",this); + cmdsource->Subscribe("/stand", this); + cmdsource->Subscribe("/starttrading", this); + cmdsource->Subscribe("/stopattack",this); + cmdsource->Subscribe("/stoptrading", this); + cmdsource->Subscribe("/study", this); cmdsource->Subscribe("/target", this); cmdsource->Subscribe("/targetcontext", this); + cmdsource->Subscribe("/targetinfo",this); cmdsource->Subscribe("/tip", this); - cmdsource->Subscribe("/motd", this); - cmdsource->Subscribe("/challenge", this); + cmdsource->Subscribe("/trade",this); + cmdsource->Subscribe("/train", this); + cmdsource->Subscribe("/unstick",this); + cmdsource->Subscribe("/use", this); + cmdsource->Subscribe("/who",this); // list players on server + cmdsource->Subscribe("/write", this); cmdsource->Subscribe("/yield", this); - cmdsource->Subscribe("/picklock",this); - cmdsource->Subscribe("/targetinfo",this); - cmdsource->Subscribe("/equip", this); - cmdsource->Subscribe("/dequip", this); - cmdsource->Subscribe("/write", this); - cmdsource->Subscribe("/pet", this); - cmdsource->Subscribe("/sit", this); - cmdsource->Subscribe("/stand", this); - cmdsource->Subscribe("/pickup", this); - cmdsource->Subscribe("/study", this); - cmdsource->Subscribe("/die", this); - cmdsource->Subscribe("/combine", this); - cmdsource->Subscribe("/show", this); - cmdsource->Subscribe("/marriage", this); - cmdsource->Subscribe("/repair", this); - cmdsource->Subscribe("/game", this); - cmdsource->Subscribe("/bank", this); - cmdsource->Subscribe("/introduce", this); - cmdsource->Subscribe("/drop", this); - cmdsource->Subscribe("/npcmenu", this); - cmdsource->Subscribe("/emote", this); } psUserCommands::~psUserCommands() { // msgqueue->Unsubscribe(MSGTYPE_CHAT,this); - cmdsource->Unsubscribe("/who", this); + cmdsource->Unsubscribe("/admin", this); + cmdsource->Unsubscribe("/advice", this); + cmdsource->Unsubscribe("/advisor", this); + cmdsource->Unsubscribe("/assist", this); + cmdsource->Unsubscribe("/attack", this); + cmdsource->Unsubscribe("/away", this); + cmdsource->Unsubscribe("/bank", this); cmdsource->Unsubscribe("/buddy", this); - cmdsource->Unsubscribe("/roll", this); - cmdsource->Unsubscribe("/pos", this); - //cmdsource->Unsubscribe("/spawn", this); - cmdsource->Unsubscribe("/unstick", this); - cmdsource->Unsubscribe("/attack", this); - cmdsource->Unsubscribe("/stopattack", this); - cmdsource->Unsubscribe("/admin", this); - cmdsource->Unsubscribe("/stoptrading", this); - cmdsource->Unsubscribe("/starttrading", this); cmdsource->Unsubscribe("/buy", this); - cmdsource->Unsubscribe("/sell", this); - cmdsource->Unsubscribe("/trade", this); + cmdsource->Unsubscribe("/cast", this); + cmdsource->Unsubscribe("/challenge", this); + cmdsource->Unsubscribe("/clear", this); + cmdsource->Unsubscribe("/combine", this); + cmdsource->Unsubscribe("/dequip", this); + cmdsource->Unsubscribe("/die", this); + cmdsource->Unsubscribe("/dig", this); + cmdsource->Unsubscribe("/drop", this); + cmdsource->Unsubscribe("/emote", this); + cmdsource->Unsubscribe("/equip", this); + cmdsource->Unsubscribe("/fish", this); + cmdsource->Unsubscribe("/game", this); cmdsource->Unsubscribe("/give", this); cmdsource->Unsubscribe("/guard", this); - cmdsource->Unsubscribe("/assist", this); + cmdsource->Unsubscribe("/help", this); cmdsource->Unsubscribe("/ignore", this); - cmdsource->Unsubscribe("/cast", this); - cmdsource->Unsubscribe("/away", this); + cmdsource->Unsubscribe("/introduce", this); cmdsource->Unsubscribe("/loot", this); - cmdsource->Unsubscribe("/clear", this); - cmdsource->Unsubscribe("/advisor", this); - cmdsource->Unsubscribe("/help", this); - cmdsource->Unsubscribe("/advice", this); - cmdsource->Unsubscribe("/train", this); + cmdsource->Unsubscribe("/marriage", this); + cmdsource->Unsubscribe("/motd", this); + cmdsource->Unsubscribe("/npcmenu", this); + cmdsource->Unsubscribe("/pet", this); + cmdsource->Unsubscribe("/picklock", this); + cmdsource->Unsubscribe("/pickup", this); + cmdsource->Unsubscribe("/pos", this); //cmdsource->Unsubscribe("/quests", this); - cmdsource->Unsubscribe("/use", this); - cmdsource->Unsubscribe("/dig", this); - cmdsource->Unsubscribe("/fish", this); + cmdsource->Unsubscribe("/repair", this); + cmdsource->Unsubscribe("/roll", this); + cmdsource->Unsubscribe("/rotate", this); + cmdsource->Unsubscribe("/sell", this); + cmdsource->Unsubscribe("/show", this); + cmdsource->Unsubscribe("/sit", this); + //cmdsource->Unsubscribe("/spawn", this); + cmdsource->Unsubscribe("/stand", this); + cmdsource->Unsubscribe("/starttrading", this); + cmdsource->Unsubscribe("/stopattack", this); + cmdsource->Unsubscribe("/stoptrading", this); + cmdsource->Unsubscribe("/study", this); cmdsource->Unsubscribe("/target", this); cmdsource->Unsubscribe("/targetcontext", this); + cmdsource->Unsubscribe("/targetinfo", this); cmdsource->Unsubscribe("/tip", this); - cmdsource->Unsubscribe("/motd", this); - cmdsource->Unsubscribe("/challenge", this); + cmdsource->Unsubscribe("/trade", this); + cmdsource->Unsubscribe("/train", this); + cmdsource->Unsubscribe("/unstick", this); + cmdsource->Unsubscribe("/use", this); + cmdsource->Unsubscribe("/who", this); + cmdsource->Unsubscribe("/write", this); cmdsource->Unsubscribe("/yield", this); - cmdsource->Unsubscribe("/picklock", this); - cmdsource->Unsubscribe("/targetinfo", this); - cmdsource->Unsubscribe("/equip", this); - cmdsource->Unsubscribe("/dequip", this); - cmdsource->Unsubscribe("/write", this); - cmdsource->Unsubscribe("/pet", this); - cmdsource->Unsubscribe("/sit", this); - cmdsource->Unsubscribe("/stand", this); - cmdsource->Unsubscribe("/pickup", this); - cmdsource->Unsubscribe("/study", this); - cmdsource->Unsubscribe("/die", this); - cmdsource->Unsubscribe("/combine", this); - cmdsource->Unsubscribe("/show", this); - cmdsource->Unsubscribe("/marriage", this); - cmdsource->Unsubscribe("/repair", this); - cmdsource->Unsubscribe("/game", this); - cmdsource->Unsubscribe("/bank", this); - cmdsource->Unsubscribe("/introduce", this); - cmdsource->Unsubscribe("/drop", this); - cmdsource->Unsubscribe("/npcmenu", this); - cmdsource->Unsubscribe("/emote", this); Modified: trunk/src/server/gem.cpp =================================================================== --- trunk/src/server/gem.cpp 2009-01-22 22:48:11 UTC (rev 2944) +++ trunk/src/server/gem.cpp 2009-01-24 06:53:09 UTC (rev 2945) @@ -1183,7 +1183,9 @@ CPrintf(CON_CMDOUTPUT, out.GetData()); } -//------------------------------------------------------------------------------------ +//-------------------------------------------------------------------------------------- +// gemActiveObject +//-------------------------------------------------------------------------------------- gemActiveObject::gemActiveObject( const char* name ) : gemObject( name ) @@ -1400,7 +1402,9 @@ return; } -/*--------------------------------------------------------------------------------------------*/ +//-------------------------------------------------------------------------------------- +// gemItem +//-------------------------------------------------------------------------------------- gemItem::gemItem(csWeakRef<psItem> item, const char* factname, @@ -1528,7 +1532,279 @@ include use of itemdata in this function. */ return true; } + //-------------------------------------------------------------------------------------- +// gemContainer +//-------------------------------------------------------------------------------------- + +gemContainer::gemContainer(csWeakRef<psItem> item, + const char* factname, + const char* filename, + InstanceID myInstance, + iSector* room, + const csVector3& pos, + float xrotangle, + float yrotangle, + float zrotangle, + int clientnum) + : gemItem(item,factname,filename,myInstance,room,pos,xrotangle,yrotangle,zrotangle,clientnum) +{ +} + +bool gemContainer::CanAdd(unsigned short amountToAdd, psItem *item, int slot) +{ + if (!item) + return false; + + PID guard = GetItem()->GetGuardingCharacterID(); + gemActor* guardingActor = GEMSupervisor::GetSingleton().FindPlayerEntity(guard); + + // Test if container is guarded by someone else who is near + if (guard.IsValid() && guard != item->GetOwningCharacterID() + && guardingActor && (guardingActor->RangeTo(this) <= 5)) + return false; + + /* We often want to see if a partial stack could be added, but we want to + * check before actually doing the splitting. So, we take an extra parameter + * and fake the stack count before calling AddToContainer with the test flag; + * we put it back when we're done. */ + + uint currentSize = 0; + gemContainer::psContainerIterator iter(this); + while (iter.HasNext()) + { + psItem* child = iter.Next(); + currentSize += child->GetTotalStackSize(); + } + if (item->GetItemSize()*amountToAdd + currentSize > itemdata->GetContainerMaxSize()) + return false; + + + unsigned short savedCount = item->GetStackCount(); + item->SetStackCount(amountToAdd); + bool result = AddToContainer(item, NULL, slot, true); + item->SetStackCount(savedCount); + return result; +} + +bool gemContainer::CanTake(Client *client, psItem* item) +{ + if (!client || !item) + return false; + + // Allow developers to take anything + if (client->GetSecurityLevel() >= GM_DEVELOPER) + return true; + + /* \note + * The check if the item is NPCOwned or NoPickup only makes + * sense if it is not possible to have NPCOwned items in a not + * NPCOwned container, or NoPickup items in a PickUpable container + */ + //not allowed to take npcowned or nopickup items in a container + if (item->GetIsNpcOwned() || item->GetIsNoPickup()) + return false; + + psItem *containeritem = GetItem(); + CS_ASSERT(containeritem); + + // Check for npc-owned or locked container + if (client->GetSecurityLevel() < GM_LEVEL_2) + { + if (containeritem->GetIsNpcOwned()) + { + return false; + } + if (containeritem->GetIsLocked()) + { + psserver->SendSystemError(client->GetClientNum(), "You cannot take an item from a locked container!"); + return false; + } + } + + // Allow if the item is pickupable and either: public, guarded by the character, or the guarding character is offline + PID guard = item->GetGuardingCharacterID(); + gemActor* guardingActor = GEMSupervisor::GetSingleton().FindPlayerEntity(guard); + + if ((!guard.IsValid() || guard == client->GetCharacterData()->GetPID() || !guardingActor) || (guardingActor->RangeTo(this) > 5)) + { + return true; + } + + return false; +} + +bool gemContainer::AddToContainer(psItem *item, Client *fromClient, int slot, bool test) +{ + // Slot changing and item creation in craft is done at the very end of event. + // A new item is created from scratch and replaces the previous item stack and all. + // Auto-transform containers will interupt event if item is changed. + // Checks in craft code to make sure original item is what is expected before the item is replaced. + + // If slot number not specified put into first open slot + if (slot == PSCHARACTER_SLOT_NONE) + { + for (int i = 0; i < SlotCount(); i++) + { + if( FindItemInSlot(i) == NULL) + { + slot = i; + break; + } + } + } + if (slot < 0 || slot >= SlotCount()) + return false; + + // printf("Adding %s to GEM container %s in slot %d.\n", item->GetName(), GetName(), slot); + + // If the destination slot is occupied, try and look for an empty slot. + if (FindItemInSlot(slot)) + return AddToContainer(item, fromClient, PSCHARACTER_SLOT_NONE, test); + + if (test) + return true; + + // If the gemContainer we are dropping the item into is not pickupable then we + // guard the item placed inside. Otherwise the item becomes public. + if (fromClient) + { + /* put the player behind the client as guard */ + item->SetGuardingCharacterID(fromClient->GetCharacterData()->GetPID()); + } + if (item->GetOwningCharacterID().IsValid()) + { + /* item comes from a player () */ + item->SetGuardingCharacterID(item->GetOwningCharacterID()); + } + + if (!GetItem()->GetIsNoPickup() && item->GetOwningCharacterID().IsValid()) + GetItem()->SetGuardingCharacterID(item->GetOwningCharacterID()); + + item->SetOwningCharacter(NULL); + item->SetContainerID(GetItem()->GetUID()); + item->SetLocInParent((INVENTORY_SLOT_NUMBER)(slot)); + item->Save(false); + itemlist.PushSmart(item); + + item->UpdateView(fromClient, eid, false); + return true; +} + +bool gemContainer::RemoveFromContainer(psItem *item,Client *fromClient) +{ + // printf("Removing %s from container now.\n", item->GetName() ); + if (itemlist.Delete(item)) + { + item->UpdateView(fromClient, eid, true); + return true; + } + else + return false; +} + +psItem* gemContainer::RemoveFromContainer(psItem *itemStack, int fromSlot, Client *fromClient, int stackCount) +{ + // printf("Removing %s from container now.\n", item->GetName() ); + + psItem* item = NULL; + bool clear = false; + + // If the stack count is the taken amount then we can delete the entire stack from the itemlist + if ( itemStack->GetStackCount() == stackCount ) + { + item = itemStack; + itemlist.Delete(itemStack); + clear = true; // Clear out the slot on the client + } + else + { + // Split out the stack for the required amount. + item = itemStack->SplitStack(stackCount); + + // Save the lowered value + itemStack->Save(false); + } + + // Send out messages about the change in the item stack. + itemStack->UpdateView(fromClient, eid, clear); + return item; +} + + +psItem *gemContainer::FindItemInSlot(int slot, int stackCount) +{ + if (slot < 0 || slot >= SlotCount()) + return NULL; + psContainerIterator it(this); + while (it.HasNext()) + { + // Check for specific slot + // These are small arrays so no need to hash index + psItem* item = it.Next(); + if (item == NULL) + { + Error1("Null item in container list."); + return NULL; + } + + // Return the item in parrent location slot + if (item->GetLocInParent() == slot) + { + // If the item is here and the stack count we want is available. + if ( stackCount == -1 || item->GetStackCount() >= stackCount ) + { + return item; + } + else + { + return NULL; + } + } + } + return NULL; +} + +gemContainer::psContainerIterator::psContainerIterator(gemContainer *containerItem) +{ + UseContainerItem(containerItem); +} + +bool gemContainer::psContainerIterator::HasNext() +{ + if (current + 1 < container->CountItems() ) + return true; + return false; +} + +psItem *gemContainer::psContainerIterator::Next() +{ + if (!HasNext()) + return NULL; + + current++; + return container->GetIndexItem(current); +} + +psItem *gemContainer::psContainerIterator::RemoveCurrent(Client *fromClient) +{ + if (current < container->CountItems() ) + { + psItem *item = container->GetIndexItem(current); + container->RemoveFromContainer(item,fromClient); + current--; // This adjusts so that the next "Next()" call actually returns the next item and doesn't skip one. + return item; + } + return NULL; +} + +void gemContainer::psContainerIterator::UseContainerItem(gemContainer *containerItem) +{ + container=containerItem; + current = SIZET_NOT_FOUND; +} + +//-------------------------------------------------------------------------------------- // gemActionLocation //-------------------------------------------------------------------------------------- @@ -3948,271 +4224,3 @@ } #endif -gemContainer::gemContainer(csWeakRef<psItem> item, - const char* factname, - const char* filename, - InstanceID myInstance, - iSector* room, - const csVector3& pos, - float rotangle, - int clientnum) - : gemItem(item,factname,filename,myInstance,room,pos,rotangle,clientnum) -{ -} - -bool gemContainer::CanAdd(unsigned short amountToAdd, psItem *item, int slot) -{ - if (!item) - return false; - - PID guard = GetItem()->GetGuardingCharacterID(); - gemActor* guardingActor = GEMSupervisor::GetSingleton().FindPlayerEntity(guard); - - // Test if container is guarded by someone else who is near - if (guard.IsValid() && guard != item->GetOwningCharacterID() - && guardingActor && (guardingActor->RangeTo(this) <= 5)) - return false; - - /* We often want to see if a partial stack could be added, but we want to - * check before actually doing the splitting. So, we take an extra parameter - * and fake the stack count before calling AddToContainer with the test flag; - * we put it back when we're done. */ - - uint currentSize = 0; - gemContainer::psContainerIterator iter(this); - while (iter.HasNext()) - { - psItem* child = iter.Next(); - currentSize += child->GetTotalStackSize(); - } - if (item->GetItemSize()*amountToAdd + currentSize > itemdata->GetContainerMaxSize()) - return false; - - - unsigned short savedCount = item->GetStackCount(); - item->SetStackCount(amountToAdd); - bool result = AddToContainer(item, NULL, slot, true); - item->SetStackCount(savedCount); - return result; -} - -bool gemContainer::CanTake(Client *client, psItem* item) -{ - if (!client || !item) - return false; - - // Allow developers to take anything - if (client->GetSecurityLevel() >= GM_DEVELOPER) - return true; - - /* \note - * The check if the item is NPCOwned or NoPickup only makes - * sense if it is not possible to have NPCOwned items in a not - * NPCOwned container, or NoPickup items in a PickUpable container - */ - //not allowed to take npcowned or nopickup items in a container - if (item->GetIsNpcOwned() || item->GetIsNoPickup()) - return false; - - psItem *containeritem = GetItem(); - CS_ASSERT(containeritem); - - // Check for npc-owned or locked container - if (client->GetSecurityLevel() < GM_LEVEL_2) - { - if (containeritem->GetIsNpcOwned()) - { - return false; - } - if (containeritem->GetIsLocked()) - { - psserver->SendSystemError(client->GetClientNum(), "You cannot take an item from a locked container!"); - return false; - } - } - - // Allow if the item is pickupable and either: public, guarded by the character, or the guarding character is offline - PID guard = item->GetGuardingCharacterID(); - gemActor* guardingActor = GEMSupervisor::GetSingleton().FindPlayerEntity(guard); - - if ((!guard.IsValid() || guard == client->GetCharacterData()->GetPID() || !guardingActor) || (guardingActor->RangeTo(this) > 5)) - { - return true; - } - - return false; -} - - -bool gemContainer::AddToContainer(psItem *item, Client *fromClient, int slot, bool test) -{ - // Slot changing and item creation in craft is done at the very end of event. - // A new item is created from scratch and replaces the previous item stack and all. - // Auto-transform containers will interupt event if item is changed. - // Checks in craft code to make sure original item is what is expected before the item is replaced. - - // If slot number not specified put into first open slot - if (slot == PSCHARACTER_SLOT_NONE) - { - for (int i = 0; i < SlotCount(); i++) - { - if( FindItemInSlot(i) == NULL) - { - slot = i; - break; - } - } - } - if (slot < 0 || slot >= SlotCount()) - return false; - - // printf("Adding %s to GEM container %s in slot %d.\n", item->GetName(), GetName(), slot); - - // If the destination slot is occupied, try and look for an empty slot. - if (FindItemInSlot(slot)) - return AddToContainer(item, fromClient, PSCHARACTER_SLOT_NONE, test); - - if (test) - return true; - - // If the gemContainer we are dropping the item into is not pickupable then we - // guard the item placed inside. Otherwise the item becomes public. - if (fromClient) - { - /* put the player behind the client as guard */ - item->SetGuardingCharacterID(fromClient->GetCharacterData()->GetPID()); - } - if (item->GetOwningCharacterID().IsValid()) - { - /* item comes from a player () */ - item->SetGuardingCharacterID(item->GetOwningCharacterID()); - } - - if (!GetItem()->GetIsNoPickup() && item->GetOwningCharacterID().IsValid()) - GetItem()->SetGuardingCharacterID(item->GetOwningCharacterID()); - - item->SetOwningCharacter(NULL); - item->SetContainerID(GetItem()->GetUID()); - item->SetLocInParent((INVENTORY_SLOT_NUMBER)(slot)); - item->Save(false); - itemlist.PushSmart(item); - - item->UpdateView(fromClient, eid, false); - return true; -} - -bool gemContainer::RemoveFromContainer(psItem *item,Client *fromClient) -{ - // printf("Removing %s from container now.\n", item->GetName() ); - if (itemlist.Delete(item)) - { - item->UpdateView(fromClient, eid, true); - return true; - } - else - return false; -} - - -psItem* gemContainer::RemoveFromContainer(psItem *itemStack, int fromSlot, Client *fromClient, int stackCount) -{ - // printf("Removing %s from container now.\n", item->GetName() ); - - psItem* item = NULL; - bool clear = false; - - // If the stack count is the taken amount then we can delete the entire stack from the itemlist - if ( itemStack->GetStackCount() == stackCount ) - { - item = itemStack; - itemlist.Delete(itemStack); - clear = true; // Clear out the slot on the client - } - else - { - // Split out the stack for the required amount. - item = itemStack->SplitStack(stackCount); - - // Save the lowered value - itemStack->Save(false); - } - - // Send out messages about the change in the item stack. - itemStack->UpdateView(fromClient, eid, clear); - return item; -} - - - - -psItem *gemContainer::FindItemInSlot(int slot, int stackCount) -{ - if (slot < 0 || slot >= SlotCount()) - return NULL; - psContainerIterator it(this); - while (it.HasNext()) - { - // Check for specific slot - // These are small arrays so no need to hash index - psItem* item = it.Next(); - if (item == NULL) - { - Error1("Null item in container list."); - return NULL; - } - - // Return the item in parrent location slot - if (item->GetLocInParent() == slot) - { - // If the item is here and the stack count we want is available. - if ( stackCount == -1 || item->GetStackCount() >= stackCount ) - { - return item; - } - else - { - return NULL; - } - } - } - return NULL; -} - -gemContainer::psContainerIterator::psContainerIterator(gemContainer *containerItem) -{ - UseContainerItem(containerItem); -} - -bool gemContainer::psContainerIterator::HasNext() -{ - if (current + 1 < container->CountItems() ) - return true; - return false; -} - -psItem *gemContainer::psContainerIterator::Next() -{ - if (!HasNext()) - return NULL; - - current++; - return container->GetIndexItem(current); -} - -psItem *gemContainer::psContainerIterator::RemoveCurrent(Client *fromClient) -{ - if (current < container->CountItems() ) - { - psItem *item = container->GetIndexItem(current); - container->RemoveFromContainer(item,fromClient); - current--; // This adjusts so that the next "Next()" call actually returns the next item and doesn't skip one. - return item; - } - return NULL; -} - -void gemContainer::psContainerIterator::UseContainerItem(gemContainer *containerItem) -{ - container=containerItem; - current = SIZET_NOT_FOUND; -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wel...@us...> - 2009-02-03 09:21:43
|
Revision: 2968 http://planeshift.svn.sourceforge.net/planeshift/?rev=2968&view=rev Author: weltall2 Date: 2009-02-03 09:21:39 +0000 (Tue, 03 Feb 2009) Log Message: ----------- additional comments by kougaro Modified Paths: -------------- trunk/src/client/cmdusers.cpp trunk/src/client/pscelclient.cpp trunk/src/server/usermanager.cpp Modified: trunk/src/client/cmdusers.cpp =================================================================== --- trunk/src/client/cmdusers.cpp 2009-02-02 10:18:01 UTC (rev 2967) +++ trunk/src/client/cmdusers.cpp 2009-02-03 09:21:39 UTC (rev 2968) @@ -336,17 +336,20 @@ return "Usage: /rotate [target] [x|reset] [y|reset] [z|reset] or /rotate [x|y|z] [angle|reset]"; GEMClientObject *object = NULL; + // if the command's target is not precised, get the object currently targeted if (words[1] == "x" || words[1] == "y" || words[1] == "z" || words[1] == "reset" || atoi(words[1])) object = psengine->GetCharManager()->GetTarget(); else object = FindEntityWithName(words[1]); csString newCmd; + // obtain the EID of the command's target if (object) { EID mappedID = object->GetEID(); newCmd.Format("/rotate eid:%u %s", mappedID.Unbox(), words.GetTail(2).GetDataSafe()); } + // for the area keyword else { newCmd.Format("/rotate %s %s", words[1].GetDataSafe(), words.GetTail(2).GetDataSafe()); Modified: trunk/src/client/pscelclient.cpp =================================================================== --- trunk/src/client/pscelclient.cpp 2009-02-02 10:18:01 UTC (rev 2967) +++ trunk/src/client/pscelclient.cpp 2009-02-03 09:21:39 UTC (rev 2968) @@ -1162,11 +1162,14 @@ void GEMClientObject::Rotate(float xRot, float yRot, float zRot) { + // calculate the rotation matrix from the axis rotation csMatrix3 xmatrix = (csMatrix3) csXRotMatrix3 (xRot); csMatrix3 ymatrix = (csMatrix3) csYRotMatrix3 (yRot); csMatrix3 zmatrix = (csMatrix3) csZRotMatrix3 (zRot); + + // multiply the matrices for the three axis together, then we apply it to the mesh pcmesh->GetMovable()->GetTransform().SetO2T (xmatrix*ymatrix*zmatrix); } Modified: trunk/src/server/usermanager.cpp =================================================================== --- trunk/src/server/usermanager.cpp 2009-02-02 10:18:01 UTC (rev 2967) +++ trunk/src/server/usermanager.cpp 2009-02-03 09:21:39 UTC (rev 2968) @@ -2146,15 +2146,19 @@ EID eID = EID(strtoul(eid_str.GetDataSafe(), NULL, 10)); if (eID.IsValid()) { + // only rotate the object if it's an item rotItem = dynamic_cast<gemItem*> (gem->FindObject(eID)); if (rotItem) { float oldxrot, oldyrot, oldzrot; rotItem->GetRotation(oldxrot, oldyrot, oldzrot); - oldxrot = oldxrot*180/PI;// rotation is stored in radians, - oldyrot = oldyrot*180/PI;// we are converting the angles - oldzrot = oldzrot*180/PI;// to degrees + // rotation is stored in radians, + // we are converting the angles to degrees + oldxrot = oldxrot*180/PI; + oldyrot = oldyrot*180/PI; + oldzrot = oldzrot*180/PI; + // the specified rotation is added to the item's current rotation float xrot=oldxrot, yrot=oldyrot, zrot=oldzrot; WordArray words(action); if (words[0] == "x") @@ -2193,12 +2197,15 @@ else zrot = 0; } - + + // rotate an item only if the client is guarding it, + // or has the right to rotate all items if (psserver->HasAccess(client, "rotate all")|| rotItem->GetItem()->GetGuardingCharacterID() == client->GetPID()) { - xrot = xrot/180*PI;// rotation is given in degrees - yrot = yrot/180*PI;// converting that to radians + // rotation is given in degrees, converting that to radians + xrot = xrot/180*PI; + yrot = yrot/180*PI; zrot = zrot/180*PI; rotItem->SetRotation(xrot, yrot, zrot); rotItem->UpdateProxList(true); @@ -2216,11 +2223,6 @@ } } } - else if(client->GetTargetObject()) - { - gemObject* object= client->GetTargetObject(); - HandleRotate(client, object->GetEID().Show(), action); - } else psserver->SendSystemError(client->GetClientNum(), "You can't rotate %s", target.GetData()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |