csRef<iDocument> ParseFile(iObjectRegistry* object_reg, const csString & name) { csRef<iVFS> vfs; csRef<iDocumentSystem> xml; csRef<iDocument> doc; const char* error; vfs = csQueryRegistry<iVFS > ( object_reg); assert(vfs); csRef<iDataBuffer> buff = vfs->ReadFile(name); if (buff == NULL) { //Error2("Could not find file: %s", name.GetData()); return NULL; } xml = csQueryRegistry<iDocumentSystem> (object_reg); if (!xml.IsValid()) xml.AttachNew(new csTinyDocumentSystem); assert(xml); doc = xml->CreateDocument(); assert(doc); error = doc->Parse( buff ); if ( error ) { Error3("Parse error in %s: %s", name.GetData(), error); return NULL; } return doc; }
void SpawnManager::RepopulateItems(psSectorInfo *sectorinfo) { csArray<psItem*> items; // Load list from database if (!cacheManager->LoadWorldItems(sectorinfo, items)) { Error1("Failed to load world items."); return; } // Now create entities and meshes, etc. for each one int spawned = 0; for (size_t i = 0; i < items.GetSize(); i++) { psItem *item = items[i]; CS_ASSERT(item); // load items not in containers if (item->GetContainerID() == 0) { //if create item returns false, then no spawn occurs if (entityManager->CreateItem( item, (item->GetFlags() & PSITEM_FLAG_TRANSIENT) ? true : false)) { // printf("Created item %d: %s\n", item->GetUID(), item->GetName() ); // item->Save(false); item->SetLoaded(); spawned++; } else { printf("Creating item '%s' (%i) failed.\n", item->GetName(), item->GetUID()); delete item; // note that the dead item is still in the array } } // load items in containers else if (item->GetContainerID()) { gemItem *citem = entityManager->GetGEM()->FindItemEntity(item->GetContainerID()); gemContainer *container = dynamic_cast<gemContainer*> (citem); if (container) { if (!container->AddToContainer(item,NULL,item->GetLocInParent())) { Error2("Cannot add item into container slot %i.\n",item->GetLocInParent()); delete item; } item->SetLoaded(); } else { Error3("Container with id %d not found, specified in item %d.", item->GetContainerID(), item->GetUID() ); delete item; } } } Debug2(LOG_SPAWN,0,"Spawned %d items.\n",spawned); }
static int MaloMesta(DWORD nCl) { char ss1[200], ss2[200]; wsprintf(ss1, " %s %s %s.", (Lan+48)->msg, FileSize_Txt(DWORDLONG(maxZapFAT1 - 1 - writeCl) * sCl_B), (Lan+47)->msg); wsprintf(ss2, " %s %s %s.", (Lan+49)->msg, FileSize_Txt(DWORDLONG(nCl) * sCl_B), (Lan+47)->msg); return Error3((Lan+190)->msg, ss1, ss2); //"Запись невозможна, на HDD LG нет свободного места."}, }
bool psCharAppearance::SetTrait(Trait * trait) { bool result = true; while (trait) { switch (trait->location) { case PSTRAIT_LOCATION_SKIN_TONE: { SetSkinTone(trait->mesh, trait->material); break; } case PSTRAIT_LOCATION_FACE: { FaceTexture(trait->material); break; } case PSTRAIT_LOCATION_HAIR_STYLE: { HairMesh(trait->mesh); break; } case PSTRAIT_LOCATION_BEARD_STYLE: { BeardMesh(trait->mesh); break; } case PSTRAIT_LOCATION_HAIR_COLOR: { HairColor(trait->shader); break; } case PSTRAIT_LOCATION_EYE_COLOR: { EyeColor(trait->shader); break; } default: { Error3("Trait(%d) unknown trait location %d",trait->uid,trait->location); result = false; break; } } trait = trait->next_trait; } return true; }
/* use some file descriptor and apply the options. Set the FD_CLOEXEC flag. */ static int xioopen_fdnum(int argc, const char *argv[], struct opt *opts, int xioflags, xiofile_t *xfd, unsigned groups, int dummy1, int dummy2, int dummy3) { char *a1; int rw = (xioflags&XIO_ACCMODE); int numfd; int result; if (argc != 2) { Error3("%s:%s: wrong number of parameters (%d instead of 1)", argv[0], argv[1], argc-1); } numfd = strtoul(argv[1], &a1, 0); if (*a1 != '\0') { Error1("error in FD number \"%s\"", argv[1]); } /* we dont want to see these fds in child processes */ if (Fcntl_l(numfd, F_SETFD, FD_CLOEXEC) < 0) { Warn2("fcntl(%d, F_SETFD, FD_CLOEXEC): %s", numfd, strerror(errno)); } Notice2("using file descriptor %d for %s", numfd, ddirection[rw]); if ((result = xioopen_fd(opts, rw, &xfd->stream, numfd, dummy2, dummy3)) < 0) { return result; } return 0; }
bool pawsTextureManager::LoadImageList( const char* listName ) { printf("Texture Manager parsing %s\n", listName); csRef<iDataBuffer> buff = vfs->ReadFile( listName ); if ( !buff || !buff->GetSize() ) { return false; } csRef<iDocument> doc = xml->CreateDocument(); const char* error = doc->Parse( buff ); if ( error ) { Error3("Error %s in %s", error, listName); return false; } csRef<iDocumentNode> root = doc->GetRoot(); if (!root) { Error2("XML error in %s", listName); return false; } csRef<iDocumentNode> topNode = root->GetNode("image_list"); if(!topNode) { Error2("Missing tag <image_list> in %s", listName); return false; } csRef<iDocumentNodeIterator> iter = topNode->GetNodes(); while ( iter->HasNext() ) { csRef<iDocumentNode> node = iter->Next(); if ( node->GetType() != CS_NODE_ELEMENT ) continue; if (elementList.Contains(node->GetAttributeValue("resource"))) continue; csRef<iPawsImage> element; if (!strcmp(node->GetValue(), "image")) element.AttachNew(new pawsImageDrawable(node)); else if (!strcmp(node->GetValue(), "frame")) element.AttachNew(new pawsFrameDrawable(node)); else Error2("Illegal node name in imagelist.xml: %s", node->GetValue() ); if(element.IsValid()) AddPawsImage(element); } return true; }
int main(void) { Error1(); Error2(); Error3(); Error4(); Error6(); printf("Pareciera que esta todo bien!!\n"); }
static int Ctrl_OutName(char *outNameF) //Проверка, что длина имени менее предельной { // char Driv[MAXDRIVE+3], Dir[MAXPATH], Name[MAXFILE], Ext[MAXEXT+3]; // fnmerge(outNameF, Driv, Dir, Name, Ext); int l = lstrlen(outNameF); if(l > 255) //if(l > 259) //Боремся с предельно длинными именвми return Error3(outNameF, "", (Lan+95)->msg); //return Error3(outNameF, "", "Число символов в полном имени файла превышает предел для Windows."); return 0;
int xiotermios_clrflag(int fd, int word, tcflag_t mask) { union { struct termios termarg; tcflag_t flags[4]; } tdata; if (Tcgetattr(fd, &tdata.termarg) < 0) { Error3("tcgetattr(%d, %p): %s", fd, &tdata.termarg, strerror(errno)); return -1; } tdata.flags[word] &= ~mask; if (Tcsetattr(fd, TCSADRAIN, &tdata.termarg) < 0) { Error3("tcsetattr(%d, TCSADRAIN, %p): %s", fd, &tdata.termarg, strerror(errno)); return -1; } return 0; }
bool psRaceInfo::LoadBaseSpeeds(iObjectRegistry* object_reg) { csRef<iVFS> vfs = csQueryRegistry<iVFS > (object_reg); csRef<iDocumentSystem> xml( csQueryRegistry<iDocumentSystem> (object_reg)); csRef<iDocument> doc = xml->CreateDocument(); csString meshFileName; meshFileName.Format("/planeshift/meshes/%s", mesh_name.GetData()); csRef<iDataBuffer> buf(vfs->ReadFile(meshFileName.GetData())); if(!buf || !buf->GetSize()) { Error2("Error loading race mesh file. %s\n", meshFileName.GetData()); return false; } const char* error = doc->Parse(buf); if(error) { Error3("Error %s loading file %s\n",error, meshFileName.GetData()); return false; } csRef<iDocumentNode> cal3dlib = doc->GetRoot(); csRef<iDocumentNode> meshfact = cal3dlib->GetNode("meshfact"); csRef<iDocumentNode> params = meshfact->GetNode("params"); csRef<iDocumentNodeIterator> animations = params->GetNodes("animation"); while(animations->HasNext()) { csRef<iDocumentNode> animation = animations->Next(); if(strcasecmp(animation->GetAttributeValue("name"),"walk") == 0) { walkBaseSpeed = animation->GetAttributeValueAsFloat("base_vel"); walkMinSpeed = animation->GetAttributeValueAsFloat("min_vel"); walkMaxSpeed = animation->GetAttributeValueAsFloat("max_vel"); } else if(strcasecmp(animation->GetAttributeValue("name"),"run") == 0) { runBaseSpeed = animation->GetAttributeValueAsFloat("base_vel"); runMinSpeed = animation->GetAttributeValueAsFloat("min_vel"); runMaxSpeed = animation->GetAttributeValueAsFloat("max_vel"); } } Debug8(LOG_STARTUP,0,"LoadedBaseSpeed Walk %.2f(%.2f,%.2f) Run %.2f(%.2f,%.2f) for %s.", walkBaseSpeed,walkMinSpeed,walkMaxSpeed,runBaseSpeed,runMinSpeed,runMaxSpeed,name.GetData()); return true; }
int ReadClast2Emul(DWORDLONG Poz, BYTE *buff) //Чтение кластера эмулятором { DWORD nSector = DWORD(Poz / sSecB); DWORD nClast = (nSector - Start_SecDir2) / sClSec2 + 1; char Ss[300]; wsprintf(Ss, "Load Dir (claster2 %d, sector %d)", nClast, nSector); if(FindStr(Ss) < 0) // return Error2("Не найдена строка", Ss); { Error3("Не найдена строка", Ss, "Эмулятор."); return 0; } if(Read_Dump(buff, sCl2_B) < 0) return -1; return 0; }
void SpawnManager::RemoveNPC(gemObject *obj) { Debug2(LOG_SPAWN,0,"RemoveNPC:%s\n",obj->GetName() ); ServerStatus::mob_deathcount++; PID pid = obj->GetPID(); Notify3(LOG_SPAWN, "Sending NPC %s disconnect msg to %zu clients.\n", ShowID(obj->GetEID()), obj->GetMulticastClients().GetSize()); if (obj->GetCharacterData()==NULL) { Error2("Character data for npc character %s was not found! Entity stays dead.\n", ShowID(pid)); return; } SpawnRule *respawn = NULL; int spawnruleid = obj->GetCharacterData()->NPC_GetSpawnRuleID(); if (spawnruleid) { // Queue for respawn according to rules respawn = rules.Get(spawnruleid, NULL); } if (!respawn) { if (spawnruleid == 0) // spawnruleid 0 is for non-respawning NPCs { Notify2(LOG_SPAWN,"Temporary NPC based on player ID %s has died. Entity stays dead.\n", ShowID(pid)); } else { Error3("Respawn rule for player %s, rule %d was not found! Entity stays dead.\n", ShowID(pid), spawnruleid); } // Remove mesh, etc from engine entityManager->RemoveActor(obj); return; } // Remove mesh, etc from engine entityManager->RemoveActor(obj); int delay = respawn->GetRespawnDelay(); PID newplayer = respawn->CheckSubstitution(pid); psRespawnGameEvent *newevent = new psRespawnGameEvent(this, delay, newplayer, respawn); psserver->GetEventManager()->Push(newevent); Notify3(LOG_SPAWN, "Scheduled NPC %s to be respawned in %.1f seconds", ShowID(newplayer), (float)delay/1000.0); }
/* retrieve the mode option and perform the creat() call. returns the file descriptor or a negative value. */ static int _xioopen_creat(const char *path, int rw, struct opt *opts) { mode_t mode = 0666; int fd; retropt_modet(opts, OPT_PERM, &mode); if ((fd = Creat(path, mode)) < 0) { Error3("creat(\"%s\", 0%03o): %s", path, mode, strerror(errno)); return STAT_RETRYLATER; } return fd; }
int xioinqopt(char what, char *arg, size_t n) { switch (what) { case 's': return xioopts.strictopts; case 'p': strncpy(arg, xioopts.pipesep, n); return 0; case 'o': return xioopts.ip4portsep; case 'l': return xioopts.logopt; default: Error3("xioinqopt('%c', \"%s\", "F_Zu"): unknown option", what, arg, n); return -1; } return 0; }
bool psShadowManager::Load(const char * filename) { csRef<iDocument> doc; csRef<iDocumentNode> root; csRef<iVFS> vfs; csRef<iDocumentSystem> xml; const char* error; vfs = psengine->GetVFS(); assert(vfs); csRef<iDataBuffer> buff = vfs->ReadFile(filename); if (buff == NULL) { return false; } xml = psengine->GetXMLParser (); doc = xml->CreateDocument(); assert(doc); error = doc->Parse( buff ); if ( error ) { Error3("Parse error in %s: %s", filename, error); return false; } if (doc == NULL) return false; root = doc->GetRoot(); if (root == NULL) { Error2("No root in XML %s", filename); return false; } csRef<iDocumentNode> shadowsNode = root->GetNode("shadows"); if (!shadowsNode) { Error2("No shadows node in %s", filename); return false; } if ((csString) shadowsNode->GetAttributeValue("enabled") == "false") DisableShadows(); else EnableShadows(); return true; }
void Tribe::GetHome(csVector3 &pos, float &radius, iSector* §or) { pos = homePos; radius = homeRadius; if(homeSector == NULL) { homeSector = npcclient->GetEngine()->FindSector(homeSectorName); if(!homeSector) { Error3("Failed to find sector for tribe %s home for homeSectorName: %s", GetName(),homeSectorName.GetDataSafe()); } } sector = homeSector; }
void psCharAppearance::ProcessAttach(csRef<iMaterialWrapper> material, const char* materialName, const char* partName) { if (!state->SetMaterial(partName, material)) { csString left, right; left.Format("Left %s", partName); right.Format("Right %s", partName); // Try mirroring if(!state->SetMaterial(left, material) || !state->SetMaterial(right, material)) { Error3("Failed to set material \"%s\" on part \"%s\"", materialName, partName); return; } } }
bool pawsStyles::LoadStyles(const csString &fileName) { csRef<iVFS> vfs = csQueryRegistry<iVFS > (objectReg); assert(vfs); csRef<iDataBuffer> buff = vfs->ReadFile(fileName); if(buff == NULL) { Error2("Could not find file: %s", fileName.GetData()); return false; } csRef<iDocumentSystem> xml; xml.AttachNew(new csTinyDocumentSystem); assert(xml); csRef<iDocument> doc = xml->CreateDocument(); assert(doc); const char* error = doc->Parse(buff); if(error) { Error3("Parse error in %s: %s", fileName.GetData(), error); return false; } csRef<iDocumentNode> root = doc->GetRoot(); if(root == NULL) return false; csRef<iDocumentNode> topNode = root->GetNode("styles"); if(topNode == NULL) { Error2("Missing <styles> tag in %s", fileName.GetData()); return false; } csRef<iDocumentNodeIterator> iter = topNode->GetNodes("style"); while(iter->HasNext()) { csRef<iDocumentNode> styleNode = iter->Next(); csString name = styleNode->GetAttributeValue("name"); if(styles.In(csString(name))) { // This is not an error anymore. Custom skins can and should supercede standard styles. //Error2("Warning: PAWS style '%s' defined more than once", name.GetData()); } else styles.Put(csString(name), styleNode); } InheritStyles(); return true; }
csRef<iDocument> ParseString(const csString & str, bool notify) { csRef<iDocumentSystem> xml; xml.AttachNew(new csTinyDocumentSystem); CS_ASSERT(xml != NULL); csRef<iDocument> doc = xml->CreateDocument(); const char* error = doc->Parse(str); if (error) { if (notify) { Error3("Error in XML: %s\nString was: %s", error, str.GetDataSafe()); } return NULL; } return doc; }
void psWorld::BuildWarpCache() { int sectorCount = engine->GetSectors()->GetCount(); Debug2(LOG_STARTUP,0,"Building warp cache for %d sectors...",sectorCount); /// Clear existing entries transarray.Empty(); transarray.SetSize(sectorCount); for(int i=0; i<sectorCount; i++) { const csSet<csPtrKey<iMeshWrapper> > &portals = engine->GetSectors()->Get(i)->GetPortalMeshes(); Debug3(LOG_STARTUP,0," %zu portal meshes for %s",portals.GetSize(), engine->GetSectors()->Get(i)->QueryObject()->GetName()); csSet<csPtrKey<iMeshWrapper> >::GlobalIterator it = portals.GetIterator(); while(it.HasNext()) { iMeshWrapper* portal_mesh = it.Next(); iPortalContainer* pc = portal_mesh->GetPortalContainer(); for(int j = 0 ; j < pc->GetPortalCount() ; j++) { iPortal* portal = pc->GetPortal(j); if(portal->CompleteSector(0)) { if(engine->GetSectors()->Find(portal->GetSector()) != -1) { const csReversibleTransform warp = portal->GetWarp(); // Check the values and issue warning for strange values. csVector3 v_o2t = warp.GetO2TTranslation(); if(fabs(v_o2t.x) > 1.0e+10 || fabs(v_o2t.y) > 1.0e+10 || fabs(v_o2t.z) > 1.0e+10) { Error3("Warpspace with very large o2t translation: %s: %s", portal->GetName(),warp.Description().GetData()); } // Apply the warp to the chache transarray[i].Set(portal->GetSector(), warp); } } } } } }
void psClientDR::HandleForcePosition(MsgEntry *me) { psForcePositionMessage msg(me, psengine->GetNetManager()->GetConnection()->GetAccessPointers()); if(last_sector != msg.sectorName) { psengine->GetZoneHandler()->HandleDelayAndAnim(msg.loadTime, msg.start, msg.dest, msg.backgroundname, msg.loadWidget); psNewSectorMessage cross(last_sector, msg.sectorName, msg.pos); msghandler->Publish(cross.msg); Error3("Sector crossed from %s to %s after forced position update.\n", last_sector.GetData(), msg.sectorName.GetData()); } else { psengine->GetZoneHandler()->HandleDelayAndAnim(msg.loadTime, msg.start, msg.dest, msg.backgroundname, msg.loadWidget); psengine->GetZoneHandler()->LoadZone(msg.pos, msg.yrot, msg.sectorName, csVector3(0.0f, 0.0f, msg.vel), true); } }
pawsWidget *PawsManager::LoadWidgetFromString(const char* widgetDefinition) { csRef<iDocument> doc; const char* error; doc=xml->CreateDocument(); error=doc->Parse(widgetDefinition); if ( error ) { Error3("Parse error in %s: %s", widgetDefinition, error); return NULL; } csRef<iDocumentNode> root,node; root = doc->GetRoot(); node = root->GetNode("widget"); pawsWidget *widget = LoadWidget(node); if (widget) widget->PostSetup(); return widget; }
EID EntityManager::CreateNPC(psCharacter *chardata, bool updateProxList, bool alwaysWatching) { csVector3 pos; float yrot; psSectorInfo *sectorinfo; iSector *sector; InstanceID instance; chardata->GetLocationInWorld(instance, sectorinfo,pos.x,pos.y,pos.z,yrot); sector = FindSector(sectorinfo->name); if (sector == NULL) { Error3("Could not resolve sector >%s< for NPC %s.", sectorinfo->name.GetData(), ShowID(chardata->GetPID())); delete chardata; return false; } return CreateNPC(chardata, instance, pos, sector, yrot, updateProxList, alwaysWatching); }
bool NameGenerationSystem::LoadDatabase( iObjectRegistry* objectReg ) { csRef<iVFS> vfs = csQueryRegistry<iVFS > ( objectReg); csRef<iDocumentSystem> xml; xml.AttachNew(new csTinyDocumentSystem); csRef<iDataBuffer> buff = vfs->ReadFile( PHONICS_LIST ); if ( !buff || !buff->GetSize() ) { Error2( "Could not load XML: %s", PHONICS_LIST ); return false; } csRef<iDocument> doc=xml->CreateDocument(); const char* error =doc->Parse(buff); if(error) { Error3( "Error parsing XML file %s: %s", PHONICS_LIST, error ); return false; } csRef<iDocumentNode> root, familyName, femaleName, maleName; if((root=doc->GetRoot())&&(familyName = root->GetNode("FAMILY_NAME")) && (femaleName = root->GetNode("FEMALE_FIRST_NAME")) && (maleName = root->GetNode("MALE_FIRST_NAME"))) { generators[0] = new NameGenerator( femaleName ); generators[1] = new NameGenerator( maleName ); generators[2] = new NameGenerator( familyName ); return true; } else { Error2("Error parsing XML file: %s", PHONICS_LIST); return false; } }
void psClientDR::HandleForcePosition(MsgEntry *me) { psForcePositionMessage msg(me, 0, msgstrings, psengine->GetEngine()); // Check if we crossed a sector boundary - if so, the player may have been // moved to an unloaded map. We must tell ZoneHandler to 1) load the // necessary maps and 2) set the player's position. if (last_sector != msg.sectorName) { psNewSectorMessage cross(last_sector, msg.sectorName, msg.pos); msghandler->Publish(cross.msg); Error3("Sector crossed from %s to %s after forced position update.\n", last_sector.GetData(), msg.sectorName.GetData()); } else { CS_ASSERT(msg.sector); if(!celclient->IsReady()) return; celclient->GetMainPlayer()->SetPosition(msg.pos, msg.yrot, msg.sector); } }
void pawsImageDrawable::Draw(int x, int y, int newWidth, int newHeight, int alpha) { int w = textureRectangle.Width(); int h = textureRectangle.Height(); if (!textureHandle) { if (debugImageErrors) Error3("Image named >%s< (%s) was not loaded and could not be drawn.",resourceName.GetDataSafe(),imageFileLocation.GetDataSafe() ); return; } if (alpha < 0) alpha = defaultAlphaValue; if ( newWidth == 0 ) newWidth = width; if ( newHeight == 0 ) newHeight = height; if (!tiled) PawsManager::GetSingleton().GetGraphics3D()->DrawPixmap(textureHandle, x, y, newWidth, newHeight, textureRectangle.xmin, textureRectangle.ymin, w, h, alpha); else { int left = x; int top = y; int right = x + newWidth; int bottom = y + newHeight; for (x=left; x<right; x+=w) { for (y=top; y<bottom; y+=h) { int dw = csMin<int>(w, right - x); int dh = csMin<int>(h, bottom - y); PawsManager::GetSingleton().GetGraphics3D()->DrawPixmap(textureHandle, x, y, dw, dh, textureRectangle.xmin, textureRectangle.ymin, dw, dh, alpha); } } } }
bool PawsManager::LoadSkinDefinition(const char* zip) { //Mount the skin printf("Mounting skin: %s\n", zip); csRef<iDataBuffer> realPath = vfs->GetRealPath(zip); if (!realPath.IsValid()) { Error2( "Could not mount skin %s. Bad virtual path.",zip); return false; } if ( !vfs->Mount(TEMP_SKIN_MOUNT, realPath->GetData() ) ) { Error2( "Could not mount skin %s!",zip); return false; } csRef<iDocument> xml = ParseFile(objectReg,TEMP_SKIN_MOUNT "/skin.xml"); if(!xml) { Error2( "Could not read skin.xml on %s!",zip); return false; } // Get the mount path csRef<iDocumentNode> root = xml->GetRoot(); if (!root) { Error2( "skin.xml badly formed on %s!",zip); return false; } root = root->GetNode("xml"); if(!root) { Error2( "Could not find xml node on %s!",zip); return false; } csRef<iDocumentNode> mount = root->GetNode("mount_path"); if ( !mount ) { Error1("There was no mount_path found in the skin.xml file. Please check the <xml> node to make sure mount_path is defined"); return false; } if (vfsPathToSkin.Length() == 0) { vfsPathToSkin = mount->GetContentsValue(); vfsPathToSkin.ReplaceAll("\\","/"); vfsPathToSkin.Append("/"); } csString mountPath = mount->GetContentsValue(); // Unmount the temp location and remount real vfs->Unmount(TEMP_SKIN_MOUNT,realPath->GetData()); // See if there is another skin with that mount path csRef<iStringArray> mounts = vfs->GetMounts(); for(size_t i = 0; i < mounts->GetSize(); i++) { csString mount = mounts->Get(i); if(mount == mountPath || mount == mountPath + "/") { Error3("The mount place (%s) for skin '%s' is already taken!",mountPath.GetData(),zip); return false; } } // mount vfs->Mount(mountPath,realPath->GetData()); // Load additional styles csString stylesFile = mountPath + "/styles.xml"; if (vfs->Exists(stylesFile) && !styles->LoadStyles(stylesFile)) { Error2("Couldn't load styles file: %s", stylesFile.GetData()); return false; } // Load additional resources csString imageFile = mountPath + "/imagelist.xml"; textureManager->LoadImageList(imageFile); return true; }
static int xioopen_tun(int argc, const char *argv[], struct opt *opts, int xioflags, xiofile_t *xfd, unsigned groups, int dummy1, int dummy2, int dummy3) { char *tundevice = NULL; char *tunname = NULL, *tuntype = NULL; int pf = /*! PF_UNSPEC*/ PF_INET; struct xiorange network; bool no_pi = false; const char *namedargv[] = { "tun", NULL, NULL }; int rw = (xioflags & XIO_ACCMODE); bool exists; struct ifreq ifr; int sockfd; char *ifaddr; int result; if (argc > 2 || argc < 0) { Error2("%s: wrong number of parameters (%d instead of 0 or 1)", argv[0], argc-1); } if (retropt_string(opts, OPT_TUN_DEVICE, &tundevice) != 0) { tundevice = strdup("/dev/net/tun"); } /*! socket option here? */ retropt_socket_pf(opts, &pf); namedargv[1] = tundevice; /* open the tun cloning device */ if ((result = _xioopen_named_early(2, namedargv, xfd, groups, &exists, opts)) < 0) { return result; } /*========================= the tunnel interface =========================*/ Notice("creating tunnel network interface"); if ((result = _xioopen_open(tundevice, rw, opts)) < 0) return result; xfd->stream.fd = result; /* prepare configuration of the new network interface */ memset(&ifr, 0,sizeof(ifr)); if (retropt_string(opts, OPT_TUN_NAME, &tunname) == 0) { strncpy(ifr.ifr_name, tunname, IFNAMSIZ); /* ok */ free(tunname); } else { ifr.ifr_name[0] = '\0'; } ifr.ifr_flags = IFF_TUN; if (retropt_string(opts, OPT_TUN_TYPE, &tuntype) == 0) { if (!strcmp(tuntype, "tap")) { ifr.ifr_flags = IFF_TAP; } else if (strcmp(tuntype, "tun")) { Error1("unknown tun-type \"%s\"", tuntype); } } if (retropt_bool(opts, OPT_IFF_NO_PI, &no_pi) == 0) { if (no_pi) { ifr.ifr_flags |= IFF_NO_PI; #if 0 /* not neccessary for now */ } else { ifr.ifr_flags &= ~IFF_NO_PI; #endif } } if (Ioctl(xfd->stream.fd, TUNSETIFF, &ifr) < 0) { Error3("ioctl(%d, TUNSETIFF, {\"%s\"}: %s", xfd->stream.fd, ifr.ifr_name, strerror(errno)); Close(xfd->stream.fd); } /*===================== setting interface properties =====================*/ /* we seem to need a socket for manipulating the interface */ if ((sockfd = Socket(PF_INET, SOCK_DGRAM, 0)) < 0) { Error1("socket(PF_INET, SOCK_DGRAM, 0): %s", strerror(errno)); sockfd = xfd->stream.fd; /* desparate fallback attempt */ } /*--------------------- setting interface address and netmask ------------*/ if (argc == 2) { if ((ifaddr = strdup(argv[1])) == NULL) { Error1("strdup(\"%s\"): out of memory", argv[1]); return STAT_RETRYLATER; } if ((result = xioparsenetwork(ifaddr, pf, &network)) != STAT_OK) { /*! recover */ return result; } socket_init(pf, (union sockaddr_union *)&ifr.ifr_addr); ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr = network.netaddr.ip4.sin_addr; if (Ioctl(sockfd, SIOCSIFADDR, &ifr) < 0) { Error4("ioctl(%d, SIOCSIFADDR, {\"%s\", \"%s\"}: %s", sockfd, ifr.ifr_name, ifaddr, strerror(errno)); } ((struct sockaddr_in *)&ifr.ifr_netmask)->sin_addr = network.netmask.ip4.sin_addr; if (Ioctl(sockfd, SIOCSIFNETMASK, &ifr) < 0) { Error4("ioctl(%d, SIOCSIFNETMASK, {\"0x%08u\", \"%s\"}, %s", sockfd, ((struct sockaddr_in *)&ifr.ifr_netmask)->sin_addr.s_addr, ifaddr, strerror(errno)); } free(ifaddr); } /*--------------------- setting interface flags --------------------------*/ applyopts_single(&xfd->stream, opts, PH_FD); if (Ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0) { Error3("ioctl(%d, SIOCGIFFLAGS, {\"%s\"}: %s", sockfd, ifr.ifr_name, strerror(errno)); } Debug2("\"%s\": system set flags: 0x%hx", ifr.ifr_name, ifr.ifr_flags); ifr.ifr_flags |= xfd->stream.para.tun.iff_opts[0]; ifr.ifr_flags &= ~xfd->stream.para.tun.iff_opts[1]; Debug2("\"%s\": xio merged flags: 0x%hx", ifr.ifr_name, ifr.ifr_flags); if (Ioctl(sockfd, SIOCSIFFLAGS, &ifr) < 0) { Error4("ioctl(%d, SIOCSIFFLAGS, {\"%s\", %hd}: %s", sockfd, ifr.ifr_name, ifr.ifr_flags, strerror(errno)); } ifr.ifr_flags = 0; if (Ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0) { Error3("ioctl(%d, SIOCGIFFLAGS, {\"%s\"}: %s", sockfd, ifr.ifr_name, strerror(errno)); } Debug2("\"%s\": resulting flags: 0x%hx", ifr.ifr_name, ifr.ifr_flags); #if LATER applyopts_named(tundevice, opts, PH_FD); #endif applyopts(xfd->stream.fd, opts, PH_FD); applyopts_cloexec(xfd->stream.fd, opts); applyopts_fchown(xfd->stream.fd, opts); if ((result = _xio_openlate(&xfd->stream, opts)) < 0) return result; return 0; }
bool GMEventManager::RemovePlayerFromGMEvents(PID playerID) { int runningEventIDAsGM; int runningEventID, gmEventID; csArray<int> completedEventIDsAsGM; csArray<int> completedEventIDs; GMEvent* gmEvent; bool eventsFound = false; runningEventID = GetAllGMEventsForPlayer(playerID, completedEventIDs, runningEventIDAsGM, completedEventIDsAsGM); // remove if partaking in an ongoing event if (runningEventID >= 0) { gmEvent = GetGMEventByID(runningEventID); if (gmEvent) { size_t PlayerIndex = GetPlayerFromEvent(playerID, gmEvent); if(PlayerIndex != SIZET_NOT_FOUND) { gmEvent->Player.DeleteIndex(PlayerIndex); eventsFound = true; } } else Error3("Cannot remove player %s from GM Event %d.", ShowID(playerID), runningEventID); } // remove ref's to old completed events csArray<int>::Iterator evIter = completedEventIDs.GetIterator(); while(evIter.HasNext()) { gmEventID = evIter.Next(); gmEvent = GetGMEventByID(gmEventID); if (gmEvent) { size_t PlayerIndex = GetPlayerFromEvent(playerID, gmEvent); if(PlayerIndex != SIZET_NOT_FOUND) { gmEvent->Player.DeleteIndex(PlayerIndex); eventsFound = true; } } else Error3("Cannot remove player %s from GM Event %d.", ShowID(playerID), runningEventID); } // ...and from the DB too if (eventsFound) db->Command("DELETE FROM character_events WHERE player_id = %u", playerID.Unbox()); // if this is a GM thats being deleted, set its GMID to UNDEFINED_GMID. if (runningEventIDAsGM >= 0) { gmEvent = GetGMEventByID(runningEventIDAsGM); if (gmEvent) { gmEvent->gmID = UNDEFINED_GMID; db->Command("UPDATE gm_events SET gm_id = %d WHERE id = %d", UNDEFINED_GMID, gmEvent->id); } else Error3("Cannot remove GM %s from Event %d.", ShowID(playerID), runningEventID); } evIter = completedEventIDsAsGM.GetIterator(); while(evIter.HasNext()) { gmEventID = evIter.Next(); gmEvent = GetGMEventByID(gmEventID); if (gmEvent) { gmEvent->gmID = UNDEFINED_GMID; db->Command("UPDATE gm_events SET gm_id = %d WHERE id = %d", UNDEFINED_GMID, gmEvent->id); } else Error3("Cannot remove GM %s from Event %d.", ShowID(playerID), gmEventID); } return true; }
void GMEventManager::HandleGMEventCommand(MsgEntry* me, Client* client) { psGMEventInfoMessage msg(me); PID RequestingPlayerID = client->GetPID(); if (msg.command == psGMEventInfoMessage::CMD_QUERY) { GMEvent* theEvent; if ((theEvent = GetGMEventByID(msg.id)) == NULL) { Error3("Client %s requested unavailable GM Event %d", client->GetName(), msg.id); return; } csString eventDesc(theEvent->eventDescription); if (theEvent->status != EMPTY) { ClientConnectionSet* clientConnections = psserver->GetConnections(); Client* target; // if this client is the GM, list the participants too if (RequestingPlayerID == theEvent->gmID) { eventDesc.AppendFmt(". Participants: %zu. Online: ", theEvent->Player.GetSize()); csArray<PlayerData>::Iterator iter = theEvent->Player.GetIterator(); while (iter.HasNext()) { if ((target = clientConnections->FindPlayer(iter.Next().PlayerID))) { eventDesc.AppendFmt("%s, ", target->GetName()); } } } else if (theEvent->status == RUNNING) // and name the running GM { if (theEvent->gmID == UNDEFINED_GMID) { eventDesc.AppendFmt(" (No GM)"); } if ((target = clientConnections->FindPlayer(theEvent->gmID))) { eventDesc.AppendFmt(" (%s)", target->GetName()); } } psGMEventInfoMessage response(me->clientnum, psGMEventInfoMessage::CMD_INFO, msg.id, theEvent->eventName.GetDataSafe(), eventDesc.GetDataSafe(), CheckEvalStatus(RequestingPlayerID, theEvent)); response.SendMessage(); } else { Error3("Client %s requested unavailable GM Event %d", client->GetName(), msg.id); } } else if (msg.command == psGMEventInfoMessage::CMD_EVAL) { GMEvent* Event; if ((Event = GetGMEventByID(msg.id)) != NULL) { // check if we should allow to comment this event. Running Gm can't evaluate it if(CheckEvalStatus(RequestingPlayerID, Event)) { WriteGMEventEvaluation(client, Event, msg.xml); psserver->SendSystemOK(client->GetClientNum(), "Thanks. Your evaluation was stored in the database."); SetEvalStatus(RequestingPlayerID, Event, false); } else { psserver->SendSystemError(client->GetClientNum(), "You can't evaluate this event."); } } else { Error3("Client %s evaluated an unavailable GM Event %d", client->GetName(), msg.id); } } else if (msg.command == psGMEventInfoMessage::CMD_DISCARD) { DiscardGMEvent(client, msg.id); } }