//------------------------------------------------------------------------------ static int Calc_Folder_(HTREEITEM hitem, char *Name_Dir, char *NameFo, int pr)//Вычисления для копирование выбранной папки на диск ПК { HTREEITEM ind = TreeView_GetChild(hwndTree, hitem); //Вошли во внутренний уровень дерева if(ind == NULL) if(pr == 0) return Error1((Lan+92)->msg); //if(pr == 0) return Error1("В указанной папке нет файлов для копирования."); else return 0; //Для вложенных пустых папок ничего не делаем char nName_Dir[512]; //Суммарный путь lstrcpy(nName_Dir, Name_Dir); lstrcat(nName_Dir, "\\"); lstrcat(nName_Dir, NameFo); for(;;) //Просмотр всего дерева от текущей папки { TV_ITEM item; char Msg[100]; item.mask = TVIF_TEXT | TVIF_PARAM; item.hItem = ind; item.pszText = Msg; item.cchTextMax = 100; if(TreeView_GetItem(hwndTree, &item) == FALSE) return Error1((Lan+33)->msg); //return Error1("Ошибка при запросе информации об элементе дерева."); if((aTree + item.lParam)->pf.type == 48 || //Очередное имя это папка (aTree + item.lParam)->pf.type == 47) //Данное имя это специальная папка { if(Calc_Folder_(ind, nName_Dir, (aTree + item.lParam)->NameF, ++pr) < 0) return -1; }//Вычисления для копирование выбранной папки на диск ПК else //Очередное имя это файл { numAllInCl += DWORD(((aTree + item.lParam)->pf.SizeF + sCl_B - 1) / sCl_B); //Суммарное число кластеров во всех копируемых файлах numAllOutCl += ((aTree + item.lParam)->pf.SizeF + BytesPerClaster - 1) / BytesPerClaster; //Суммарный число выходных кластеров numAllFi++; //Число копируемых файлах } ind = TreeView_GetNextSibling(hwndTree, ind); //Следующая запись на том же уровне дерева if(ind == NULL) break; //Больше записей данного уровня нет } return 0;
void pawsConfigEntityLabels::SetDefault() { if (!CreatureRBG->SetActive("mouse")) { Error1("No widget with such name"); return; } if (!ItemRBG->SetActive("mouse")) { Error1("No widget with such name"); return; } visGuildCheck->SetState(true); labelColors[ENTITY_DEFAULT] = defLabelColors[ENTITY_DEFAULT]; labelColors[ENTITY_PLAYER] = defLabelColors[ENTITY_PLAYER]; labelColors[ENTITY_DEV] = defLabelColors[ENTITY_DEV]; labelColors[ENTITY_TESTER] = defLabelColors[ENTITY_TESTER]; labelColors[ENTITY_DEAD] = defLabelColors[ENTITY_DEAD]; labelColors[ENTITY_GM1] = defLabelColors[ENTITY_GM1]; labelColors[ENTITY_GM25] = defLabelColors[ENTITY_GM25]; labelColors[ENTITY_NPC] = defLabelColors[ENTITY_NPC]; labelColors[ENTITY_GROUP] = defLabelColors[ENTITY_GROUP]; labelColors[ENTITY_GUILD] = defLabelColors[ENTITY_GUILD]; dirty = true; }
//------------------------------------------------------------------------------ int Load_Dir(void) //Загрузка кластера каталога { //Чтение кластера каталога (каталога может и не существовать и, в том числе каталога самого верхнего уровня) //Обновление каталога (добавление строки нового файла) и в том числе создание нового каталога DWORD nSector = Start_SecDir1 + (ClStDir - 1) * sClSec; //Номер сектора по номеру кластера if(ReadClast1_P(nSector, bufDir) < 0) return -1; //Чтение кластера s_Kat = (One_Str_Cat *)bufDir; int prPoint = 0; //Признак наличия каталогов с точкой как признак правильности структуры ns_Dir = 0; //Номер свободной строки каталога for(; ns_Dir<4*sClSec; ns_Dir++) //По всем возможным записям в одном кластере каталога (В каждом секторе 4 записи) { if((s_Kat + ns_Dir)->pf.type == 0) break; //Конец записей каталога DWORD NamePoint = *((DWORD*)&(s_Kat + ns_Dir)->Name); if(NamePoint == 0x00002E00) //Это одна точка т.е. кластер текущего каталога { if(ns_Dir == 0) prPoint++; continue; } if(NamePoint == 0x2E002E00) //Это две точки т.е. кластер предыдущего каталога { if(ns_Dir == 1) prPoint++; continue; } WORD NameDel = *((WORD*)&(s_Kat + ns_Dir)->Name); if(NameDel == 0xE500 && (s_Kat + ns_Dir)->pf.ClSt == 0) break;//Это удаленное имя т.е. свободная строка } if(prPoint != 2) return Error1((Lan+96)->msg); //"Нарушена структура каталога." if(ns_Dir < 2 || ns_Dir >= 4*sClSec) return Error1((Lan+181)->msg); //"В каталоге нет места для новой записи."
bool pawsConfigAutoexec::PostSetup() { // setup the widget. Needed in the xml file are a Checkbox (to enable and disable autoexec) // and two multiline edit boxes for the general and character commands autoexec = psengine->GetAutoexec(); if(!autoexec) { Error1("Couldn't find Autoexec!"); return false; } enabled = dynamic_cast<pawsCheckBox*>(FindWidget("enabled")); if (!enabled) { Error1("Could not locate enabled widget!"); return false; } generalCommandBox = dynamic_cast<pawsMultilineEditTextBox*>(FindWidget("GeneralCommandBox")); if (!generalCommandBox) { Error1("Could not locate GeneralCommandBox widget!"); return false; } charCommandBox = dynamic_cast<pawsMultilineEditTextBox*>(FindWidget("CharCommandBox")); if (!generalCommandBox) { Error1("Could not locate CharCommandBox widget!"); return false; } drawFrame(); return true; }
bool pawsConfigTooltips::PostSetup() { EnableTooltips = (pawsCheckBox*)FindWidget("EnableTooltips"); if (!EnableTooltips) { Error1("Could not locate EnableTooltips widget!"); return false; } EnableBgColor = (pawsCheckBox*)FindWidget("EnableBgColor"); if (!EnableBgColor) { Error1("Could not locate EnableBgColor widget!"); return false; } TooltipBgColor = (pawsTextBox*)FindWidget("BgColorFrame"); if (!TooltipBgColor) { Error1("Could not locate BgColorFrame widget!"); return false; } TooltipFontColor = (pawsTextBox*)FindWidget("FontColorFrame"); if (!TooltipFontColor) { Error1("Could not locate FontColorFrame widget!"); return false; } TooltipShadowColor = (pawsTextBox*)FindWidget("ShadowColorFrame"); if (!TooltipShadowColor) { Error1("Could not locate ShadowColorFrame widget!"); return false; } return true; }
CombatManager::CombatManager(CacheManager* cachemanager, EntityManager* entitymanager) : pvp_region(NULL) { randomgen = psserver->rng; cacheManager = cachemanager; entityManager = entitymanager; calc_damage = psserver->GetMathScriptEngine()->FindScript("Calculate Damage"); calc_decay = psserver->GetMathScriptEngine()->FindScript("Calculate Decay"); if ( !calc_damage ) { Error1("Calculate Damage Script could not be found. Check the math_scripts DB table."); } else if ( !calc_decay ) { Error1("Calculate Decay Script could not be found. Check the math_scripts DB table."); } else { targetLocations.Push(PSCHARACTER_SLOT_HELM); targetLocations.Push(PSCHARACTER_SLOT_TORSO); targetLocations.Push(PSCHARACTER_SLOT_ARMS); targetLocations.Push(PSCHARACTER_SLOT_GLOVES); targetLocations.Push(PSCHARACTER_SLOT_LEGS); targetLocations.Push(PSCHARACTER_SLOT_BOOTS); } staminacombat = psserver->GetMathScriptEngine()->FindScript("StaminaCombat"); Subscribe(&CombatManager::HandleDeathEvent, MSGTYPE_DEATH_EVENT, NO_VALIDATION); }
int xioparsenetwork_ip4(const char *rangename, struct xiorange *range) { struct hostent *maskaddr; struct in_addr *netaddr_in = &range->netaddr.ip4.sin_addr; struct in_addr *netmask_in = &range->netmask.ip4.sin_addr; char *rangename1; /* a copy of rangename with writing allowed */ char *delimpos; /* absolute address of delimiter */ unsigned int bits; /* netmask bits */ if ((rangename1 = strdup(rangename)) == NULL) { Error1("strdup(\"%s\"): out of memory", rangename); return STAT_RETRYLATER; } if (delimpos = strchr(rangename1, '/')) { char *endptr; bits = strtoul(delimpos+1, &endptr, 10); if (! ((*(delimpos+1) != '\0') && (*endptr == '\0'))) { Error1("not a valid netmask in \"%s\"", rangename); bits = 32; /* most secure selection */ } else if (bits > 32) { Error1("netmask \"%s\" is too large", rangename); bits = 32; } if (bits <= 0) { netmask_in->s_addr = 0; } else { netmask_in->s_addr = htonl((0xffffffff << (32-bits))); } } else if (delimpos = strchr(rangename1, ':')) { if ((maskaddr = Gethostbyname(delimpos+1)) == NULL) { /* note: cast is req on AIX: */ Error2("gethostbyname(\"%s\"): %s", delimpos+1, h_errno == NETDB_INTERNAL ? strerror(errno) : (char *)hstrerror(h_errno)); return STAT_NORETRY; } netmask_in->s_addr = *(uint32_t *)maskaddr->h_addr_list[0]; } else { Error1("xioparsenetwork_ip4(\"%s\",,): missing netmask delimiter", rangename); free(rangename1); return STAT_NORETRY; } { struct hostent *nameaddr; *delimpos = 0; if ((nameaddr = Gethostbyname(rangename1)) == NULL) { /* note: cast is req on AIX: */ Error2("gethostbyname(\"%s\"): %s", rangename1, h_errno == NETDB_INTERNAL ? strerror(errno) : (char *)hstrerror(h_errno)); free(rangename1); return STAT_NORETRY; } netaddr_in->s_addr = *(uint32_t *)nameaddr->h_addr_list[0]; } free(rangename1); return STAT_OK; }
bool pawsTreeNode::Load(iDocumentNode* node) { csRef<iDocumentNodeIterator> xmlChildren, xmlAttrList; csRef<iDocumentNode> xmlChild, xmlAttr; csString factory; pawsWidget* childAsWidget; pawsTreeNode* childNode; Clear(); name = node->GetAttributeValue("name"); xmlChildren = node->GetNodes("widget"); while(xmlChildren->HasNext()) { xmlChild = xmlChildren->Next(); factory = xmlChild->GetAttributeValue("factory"); childAsWidget = PawsManager::GetSingleton().CreateWidget(factory); if(!childAsWidget) { Error2("Could not create node from factory: %s", factory.GetData()); return false; } childNode = dynamic_cast<pawsTreeNode*>(childAsWidget); if(childNode == NULL) { Error1("Created node is not pawsTreeNode"); return false; } InsertChild(childNode); if(!childNode->Load(xmlChild)) { Error1("Node failed to load"); return false; } } attrList.DeleteAll(); xmlAttrList = node->GetNodes("attr"); while(xmlAttrList->HasNext()) { xmlAttr = xmlAttrList->Next(); SetAttr(xmlAttr->GetAttributeValue("name"), xmlAttr->GetAttributeValue("value")); } if(tree != NULL) tree->NodeChanged(); csString collapsed = node->GetAttributeValue("collapsed"); if(collapsed == "yes") CollapseAll(); return true; }
bool GMEventManager::Initialise(void) { GMEvent* ongoingGMEvent; // load any existing gm events from database Result events(db->Select("SELECT * from gm_events order by id")); if (events.IsValid()) { for (unsigned long e=0; e<events.Count(); e++) { ongoingGMEvent = new GMEvent; ongoingGMEvent->id = events[e].GetInt("id"); ongoingGMEvent->status = static_cast<GMEventStatus>(events[e].GetInt("status")); ongoingGMEvent->gmID = events[e].GetInt("gm_id"); ongoingGMEvent->EndTime = 0; ongoingGMEvent->eventName = csString(events[e]["name"]); ongoingGMEvent->eventDescription = csString(events[e]["description"]); gmEvents.Push(ongoingGMEvent); // setup next available id if (ongoingGMEvent->id >= nextEventID) nextEventID = ongoingGMEvent->id + 1; } // load registered players from database Result registeredPlayers(db->Select("SELECT * from character_events order by event_id")); if (registeredPlayers.IsValid()) { PlayerData eventPlayer; int eventID; for (unsigned long rp=0; rp<registeredPlayers.Count(); rp++) { eventID = registeredPlayers[rp].GetInt("event_id"); eventPlayer.PlayerID = registeredPlayers[rp].GetInt("player_id"); eventPlayer.CanEvaluate = (registeredPlayers[rp]["vote"] == NULL); if ((ongoingGMEvent = GetGMEventByID(eventID)) != NULL) ongoingGMEvent->Player.Push(eventPlayer); else { Error1("GMEventManager: gm_events / character_events table mismatch."); return false; // ermm.. somethings gone wrong with the DB!!! } } } else { Error1("GMEventManager: character_events table is not valid."); return false; } return true; } Error1("GMEventManager: gm_events table is not valid."); return false; }
bool pawsConfigTooltips::LoadDefaults() { csString fileName; if( psengine->GetVFS()->Exists(PawsManager::GetSingleton().getToolTipSkinPath()) ) fileName = PawsManager::GetSingleton().getToolTipSkinPath(); // skin.zip else fileName = CONFIG_TOOLTIPS_FILE_NAME_DEF; // data/options csRef<iDocument> ToolTipdoc; csRef<iDocumentNode> ToolTiproot,TooltipsNode; csString TooltipOption; ToolTipdoc = ParseFile(PawsManager::GetSingleton().GetObjectRegistry(), fileName); if (ToolTipdoc == NULL) { Error1("Failed to parse file"); return false; } ToolTiproot = ToolTipdoc->GetRoot(); if (ToolTiproot == NULL) { Error1("File has no XML root"); return false; } TooltipsNode = ToolTiproot->GetNode("tooltips"); if (TooltipsNode == NULL) { Error1("File has no <tooltips> tag"); return false; } else { csRef<iDocumentNodeIterator> ToolTipoNodes = TooltipsNode->GetNodes(); while(ToolTipoNodes->HasNext()) { csRef<iDocumentNode> TooltipOption = ToolTipoNodes->Next(); csString ToolTipnodeName (TooltipOption->GetValue()); if (ToolTipnodeName == "enable_tooltips") defToolTipEnable = TooltipOption->GetAttributeValueAsBool("value"); if (ToolTipnodeName == "enable_bgcolor") defToolTipEnableBgColor = TooltipOption->GetAttributeValueAsBool("value"); if (ToolTipnodeName == "bgcolor") defTooltipsColors[0] = TooltipOption->GetAttributeValueAsInt("value"); if (ToolTipnodeName == "fontcolor") defTooltipsColors[1] = TooltipOption->GetAttributeValueAsInt("value"); if (ToolTipnodeName == "shadowcolor") defTooltipsColors[2] = TooltipOption->GetAttributeValueAsInt("value"); } } return true; }
void psClientDR::HandleStatsUpdate( MsgEntry* me ) { psStatDRMessage statdrmsg(me); GEMClientActor* gemObject = (GEMClientActor*)celclient->FindObject( statdrmsg.entityid ); if (!gemObject) { Error2("Stat request failed because CelClient not ready for %s", ShowID(statdrmsg.entityid)); return; } // Dirty short cut to allways display 0 HP when dead. if (!gemObject->IsAlive() && statdrmsg.hp) { //printf("clientdr 275 dead"); Error1("Server report HP but object is not alive"); statdrmsg.hp = 0; statdrmsg.hp_rate = 0; } // Check if this client actor was updated GEMClientActor* mainActor = celclient->GetMainPlayer(); if (mainActor == gemObject) { gemObject->GetVitalMgr()->HandleDRData(statdrmsg,"Self"); } else { // Publish Vitals data using EntityID csString ID; ID.Append(gemObject->GetEID().Unbox()); gemObject->GetVitalMgr()->HandleDRData(statdrmsg, ID.GetData() ); } //It is not an else if so Target is always published if (psengine->GetCharManager()->GetTarget() == gemObject) gemObject->GetVitalMgr()->HandleDRData(statdrmsg,"Target"); if (mainActor != gemObject && gemObject->IsGroupedWith(celclient->GetMainPlayer()) ) { if (!groupWindow) { // Get the windowMgr pawsWidget* widget = PawsManager::GetSingleton().FindWidget("GroupWindow"); groupWindow = (pawsGroupWindow*)widget; if (!groupWindow) { Error1("Group Window Was Not Found. Bad Error"); return; } } groupWindow->SetStats(gemObject); } }
bool pawsNpcDialogWindow::LoadSetting() { csRef<iDocument> doc; csRef<iDocumentNode> root,npcDialogNode, npcDialogOptionsNode; csString option; doc = ParseFile(psengine->GetObjectRegistry(), CONFIG_NPCDIALOG_FILE_NAME); if(doc == NULL) { //load the default configuration file in case the user one fails (missing or damaged) doc = ParseFile(psengine->GetObjectRegistry(), CONFIG_NPCDIALOG_FILE_NAME_DEF); if(doc == NULL) { Error2("Failed to parse file %s", CONFIG_NPCDIALOG_FILE_NAME_DEF); return false; } } root = doc->GetRoot(); if(root == NULL) { Error1("npcdialog_def.xml or npcdialog.xml has no XML root"); return false; } npcDialogNode = root->GetNode("npcdialog"); if(npcDialogNode == NULL) { Error1("npcdialog_def.xml or npcdialog.xml has no <npcdialog> tag"); return false; } // Load options for the npc dialog npcDialogOptionsNode = npcDialogNode->GetNode("npcdialogoptions"); if(npcDialogOptionsNode != NULL) { csRef<iDocumentNodeIterator> oNodes = npcDialogOptionsNode->GetNodes(); while(oNodes->HasNext()) { csRef<iDocumentNode> option = oNodes->Next(); csString nodeName(option->GetValue()); if(nodeName == "usenpcdialog") { //showWindow->SetState(!option->GetAttributeValueAsBool("value")); useBubbles = option->GetAttributeValueAsBool("value"); } } } return true; }
int FN_A (double *x, double *res) { int j; FillStructs_A (x); *res = SCALE0 * Error1 (TheEdges[0][I], TheCameraPositions[0], TheLines[I]); for (j=1; j < m; ++j) *res += Error1 (TheEdges[j][I], TheCameraPositions[j], TheLines[I]); return 0; }
gemNPC* EntityManager::CloneNPC ( psCharacter *chardata ) { csVector3 pos; float yrot = 0.0F; iSector *sector; CS_ASSERT( chardata != NULL ); // Adjust Position of npc from owners pos chardata->GetActor()->GetPosition( pos, yrot, sector ); float deltax = psserver->GetRandom(6)/4 - 1.5; float deltaz = psserver->GetRandom(6)/4 - 1.5; PID npcPID(this->CopyNPCFromDatabase( chardata->GetPID(), pos.x + deltax, pos.y, pos.z + deltaz, // Set position some distance from parent yrot, sector->QueryObject()->GetName(), 0,NULL, NULL)); // Keep name of parent if (!npcPID.IsValid()) { Error1( "Could not clone the master NPC ."); return NULL; } // Prepare NPC client to the new npc psserver->npcmanager->NewNPCNotify(npcPID, chardata->GetPID(), 0 ); // Create npc using new ID this->CreateNPC( npcPID , false); //Do not update proxList, we will do that later. gemNPC * npc = GEMSupervisor::GetSingleton().FindNPCEntity( npcPID ); if (npc == NULL) { Error1("Could not find GEM and set its location."); return NULL; } db->Command("INSERT INTO npc_knowledge_areas(player_id, area, priority) VALUES (%d, 'Pet %s 1', '1')", npcPID.Unbox(), npc->GetCharacterData()->GetRaceInfo()->name.GetData() ); psServer::CharacterLoader.SaveCharacterData( npc->GetCharacterData(), npc, false ); psserver->npcmanager->ControlNPC( npc ); // Add npc to all nearby clients npc->UpdateProxList( true ); return npc; }
void PawsManager::CreateYesNoBox( const char* message, pawsWidget* notify, bool modal ) { pawsYesNoBox* yesNoBox = (pawsYesNoBox*)FindWidget("YesNoWindow"); if ( !yesNoBox ) { LoadWidget("yesno.xml"); yesNoBox = (pawsYesNoBox*)FindWidget("YesNoWindow"); if ( !yesNoBox ) { Error1("Cannot Load YesNo Window"); return; } } yesNoBox->MoveTo( (graphics2D->GetWidth() - yesNoBox->GetActualWidth(512) ) / 2, (graphics2D->GetHeight() - yesNoBox->GetActualHeight(256))/2 ); yesNoBox->SetText( Translate(message) ); yesNoBox->Show(); if ( modal ) SetModalWidget(yesNoBox); if ( notify ) yesNoBox->SetNotify(notify); }
void PawsManager::CreateWarningBox( const char* message, pawsWidget* notify, bool modal ) { pawsOkBox* ok = (pawsOkBox*)FindWidget("OkWindow"); if ( !ok ) { LoadWidget("ok.xml"); ok = (pawsOkBox*)FindWidget("OkWindow"); if ( !ok ) { Error1("Cannot load the ok window!"); return; } } ok->Show(); ok->SetText( message ); ok->MoveTo( (graphics2D->GetWidth() - ok->GetActualWidth(512) ) / 2, (graphics2D->GetHeight() - ok->GetActualHeight(256))/2 ); if ( notify ) ok->SetNotify( notify ); if ( modal ) SetModalWidget( ok ); }
pawsWidget * PawsManager::LoadWidget(iDocumentNode *widgetNode ) { pawsWidget * widget; csString factory; if ( strcmp( widgetNode->GetValue(), "widget" ) == 0 ) // old syntax is <widget factory="bla"....> factory = widgetNode->GetAttributeValue( "factory" ); else factory = widgetNode->GetValue(); // new syntax is using factory name as tag name directly: <pawsChatWindow ....> if ( factory.Length() == 0 ) { Error1("Could not read factory from XML node. Error in XML"); return NULL; } widget = CreateWidget( factory ); if ( !widget ) { Error2( "Failed to create widget %s", factory.GetData() ); return NULL; } if (!widget->Load(widgetNode)) { Error3("Widget %s failed to load %s", widget->GetName(), factory.GetData() ); delete widget; return NULL; } return widget; }
void psMovementManager::SetRunToPos(psPoint& mouse) { if (!ready || !actor) return; csVector3 tmp, tmpDiff; iMeshWrapper *mesh = psengine->GetPSCamera()->Get3DPointFrom2D(mouse.x, mouse.y, &tmp, &tmpDiff); if (mesh) { // Stop and remove run-to marker, if one exists psengine->GetEffectManager()->DeleteEffect(runToMarkerID); runToMarkerID = 0; iSector* sector = actor->Movement().GetSector(); csRef<iMeshWrapper> actormesh = actor->GetMesh(); runToMarkerID = psengine->GetEffectManager()->RenderEffect("marker", sector, tmp, actormesh); runToDiff = tmpDiff; lastDist = tmpDiff.SquaredNorm() + 1.0f; } else { Error1("Failed to find mesh for SetRunToPos"); } }
/** * A character is defined to be a trainer if there are * trainer item categories for the character. * * @return Return true if the character is a trainer. */ bool psTrainerInfo::Load(PID pid) { bool isTrainer = false; Result trainerSkills(db->Select("SELECT * from trainer_skills where player_id=%u", pid.Unbox())); if (trainerSkills.IsValid()) { int i,count=trainerSkills.Count(); for (i=0;i<count;i++) { psSkillInfo * skillInfo = FindSkill(atoi(trainerSkills[i]["skill_id"])); if (!skillInfo) { Error1("Error! Skill could not be loaded. Skipping.\n"); continue; } psTrainerSkill * skill = new psTrainerSkill; skill->skill = skillInfo; skill->max_rank = atoi(trainerSkills[i]["max_rank"]); skill->min_rank = atoi(trainerSkills[i]["min_rank"]); skill->min_faction = atof(trainerSkills[i]["min_faction"]); skills.Push(skill); isTrainer = true; } } return isTrainer; }
bool psNetConnection::Connect(const char *servaddr, int port) { int err; if (IsReady() || server) DisConnect(); //@@@ DEBUG // Debug2(LOG_NET, 0,"psNetConnection::Connect this=%p",this); server = new Connection; server->addr.sin_family = AF_INET; server->addr.sin_port = htons(port); err = GetIPByName (&server->addr, servaddr); if (err) { delete server; server = NULL; return false; } shouldRun = true; thread.AttachNew( new CS::Threading::Thread(this, true) ); if (!thread->IsRunning()) { Error1("Couldn't Start Thread!"); return false; } return true; }
void pawsLoadWindow::InitAnim(csVector2 start, csVector2 dest, csTicks delay) { //if we lack the picture for the anim we don't render it if(!dot) { Error1("Couldn't find the picture to be used for the movement anim. Animation Aborted."); return; } float length; renderAnim = true; startFrom = 0; lastPos = start; destination = dest; //adjust the anim to resolution lastPos.x = GetActualWidth((int)lastPos.x); lastPos.y = GetActualHeight((int)lastPos.y); destination.x = GetActualWidth((int)destination.x); destination.y = GetActualHeight((int)destination.y); positions.DeleteAll(); csVector2 direction = destination - lastPos; length = direction.Norm(); numberDot = (int)ceil(length / 40); //we make the dots complete a bit before the end of the delay so it's //possible to see the last dot delayBetDot = ((delay * 1000)*0.9) / numberDot; }
bool psEffectObjDecal::Render(const csVector3 &up) { static unsigned int uniqueID = 0; csString meshName = "effect_decal_"; meshName += uniqueID++; // create a nullmesh as placeholder mesh = engine->CreateMeshWrapper("crystalspace.mesh.object.null", meshName); mesh->GetFlags().Set(CS_ENTITY_NOHITBEAM); csRef<iNullMeshState> state = scfQueryInterface<iNullMeshState> (mesh->GetMeshObject()); if (!state) { Error1("No NullMeshState."); return false; } state->SetRadius(1.0); // do the up vector objUp = up; csReversibleTransform rt; rt.LookAt(csVector3(up.x, up.z, up.y), csVector3(0,2,1)); matUp = rt.GetT2O(); matBase = matUp; // common flags decalTemplate->SetZBufMode(zFunc); decalTemplate->SetRenderPriority(priority); decalTemplate->SetMixMode(mixmode); decal = 0; return true; }
static int CreateNewFolder(void) //Создание новой папки на HDD рекордера { DWORD nCl = 2; for(; nCl<maxZapFAT1; nCl++) //Просмотр FAT для поиска первого свободного кластера if(*(c_FAT1 + nCl) == 0) break; if(nCl >= maxZapFAT1) return Error1((Lan+190)->msg); //"Запись невозможна, на HDD LG нет свободного места."}, ZeroMemory(bufIO, sCl_B); //Все очистили SYSTEMTIME sysTime; GetLocalTime(&sysTime); One_Str_Cat *Kat = (One_Str_Cat *)bufIO; //Каталог *(DWORD *)(Kat+0)->Name = 0x00002E00; //Это одна точка т.е. кластер текущего каталога *(DWORD *)(Kat+1)->Name = 0x2E002E00; //Это две точки т.е. кластер предыдущего каталога (Kat+0)->pf.type = (Kat+1)->pf.type = 48; //Тип папка (Kat+0)->pf.ClSt = nCl_1 = nCl; //Номер кластера текущего каталога (Kat+1)->pf.ClSt = ClStDir; //Номер кластера родительского каталога (Kat+0)->pf.Sec = (Kat+1)->pf.Sec = sysTime.wSecond; (Kat+0)->pf.Min = (Kat+1)->pf.Min = sysTime.wMinute; (Kat+0)->pf.Hour = (Kat+1)->pf.Hour = sysTime.wHour; (Kat+0)->pf.Day = (Kat+1)->pf.Day = sysTime.wDay; (Kat+0)->pf.Mon = (Kat+1)->pf.Mon = sysTime.wMonth; (Kat+0)->pf.Year = (Kat+1)->pf.Year = sysTime.wYear; #if !defined EMULATOR_HDD //Режим эмулятора if(WriteClast1P(nCl, bufIO) < 0) return -1; //Запись кластера #endif *(c_FAT1 + nCl) = 0x0FFFFFFF; //Признак конца цепочки return Change_Dir_For_Folder(NameFoFi); //Изменение каталога (запись новой папки) }
Client* ClientConnectionSet::Find(const char* name) { if(!name) { Error1("name == 0!"); return NULL; } CS::Threading::RecursiveMutexScopedLock lock(mutex); AddressHash::GlobalIterator it(addrHash.GetIterator()); Client* p = NULL; while(it.HasNext()) { p = it.Next(); if(!p->GetName()) continue; if(!strcasecmp(p->GetName(), name)) break; p = NULL; } if(p && p->IsReady()) return p; else return NULL; }
bool EntityManager::AddRideRelation(gemActor *rider, gemActor *mount) { if(!rider || !mount) { Error1("Wrong pointers in AddRideRelation()"); return false; } if(rider->GetMount()) { psserver->SendSystemError(rider->GetClientID(), "You are already on a mount."); return false; } psCharacter *mountChar = mount->GetCharacterData(); RemoveActor(mount); CacheManager::GetSingleton().RemoveFromCache(CacheManager::GetSingleton().MakeCacheName("char",mountChar->GetPID().Unbox())); rider->SetMount(mountChar); rider->UpdateProxList(true); float movMod = mountChar->GetRaceInfo()->GetSpeedModifier(); if( movMod != rider->GetCharacterData()->GetRaceInfo()->GetSpeedModifier()) { psMoveModMsg modMsg(rider->GetClientID(), psMoveModMsg::MULTIPLIER, csVector3(movMod), movMod); modMsg.SendMessage(); } return true; }
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); }
/* register the sub process pid for passing of signals of type signum. Only for SIGHUP, SIGINT, and SIGQUIT! returns 0 on success or <0 if an error occurred */ int xio_opt_signal(pid_t pid, int signum) { struct socat_sig_desc *sigdesc; if ((sigdesc = socat_get_sig_desc(signum)) == NULL) { Error("sub process registered for unsupported signal"); return -1; } if (sigdesc->sig_use >= SOCAT_MAXPIDS) { Error1("too many sub processes registered for signal %d", signum); return -1; } if (sigdesc->sig_use == 0) { /* the special signal handler has not been registered yet - do it now */ #if HAVE_SIGACTION struct sigaction act; memset(&act, 0, sizeof(struct sigaction)); act.sa_flags = 0/*|SA_RESTART*/; act.sa_handler = socatsignalpass; sigfillset(&act.sa_mask); if (Sigaction(signum, &act, NULL) < 0) { /*! man does not say that errno is defined */ Warn3("sigaction(%d, %p, NULL): %s", signum, &act, strerror(errno)); } #else Signal(signum, socatsignalpass); #endif /* !HAVE_SIGACTION */ } sigdesc->sig_pids[sigdesc->sig_use++] = pid; return 0; }
//------------------------------------------------------------------------------ int Change_Dir_For_File(char *NameF) //Изменение каталога (внесение нового файла) { for(; ns_Dir<4*sClSec; ns_Dir++) //По всем возможным записям в одном кластере каталога (В каждом секторе 4 записи) { if((s_Kat + ns_Dir)->pf.type == 0) break; //Конец записей каталога WORD NameDel = *((WORD*)&(s_Kat + ns_Dir)->Name); if(NameDel == 0xE500 && (s_Kat + ns_Dir)->pf.ClSt == 0) break;//Это удаленное имя т.е. свободная строка } if(ns_Dir >= 4*sClSec) return Error1((Lan+181)->msg); //"В каталоге нет места для новой записи." ZeroMemory(s_Kat+ns_Dir, sizeof(One_Str_Cat)); //Все очистили char Driv[MAXDRIVE], Dir[MAXPATH], Name[MAXFILE], Ext[MAXEXT]; fnsplit(NameF, Driv, Dir, Name, Ext); NameToKat(Name, Ext, s_Kat+ns_Dir); //Формирование имени файла в Unicode SYSTEMTIME sysTime; FILETIME TimeF; //Дата и время входного файла FileTimeToLocalFileTime(&Time_inF, &TimeF); FileTimeToSystemTime(&TimeF, &sysTime); (s_Kat+ns_Dir)->pf.type = 32; //Тип файл (s_Kat+ns_Dir)->pf.ClSt = nCl_1; //Номер кластера начала файла (s_Kat+ns_Dir)->pf.Sec = sysTime.wSecond; (s_Kat+ns_Dir)->pf.Min = sysTime.wMinute; (s_Kat+ns_Dir)->pf.Hour = sysTime.wHour; (s_Kat+ns_Dir)->pf.Day = sysTime.wDay; (s_Kat+ns_Dir)->pf.Mon = sysTime.wMonth; (s_Kat+ns_Dir)->pf.Year = sysTime.wYear; (s_Kat+ns_Dir)->pf.SizeF = Size_inF.QuadPart; Add_Item_To_Tree(NameF); //Добавления строки в дерево
bool psMerchantInfo::Load(PID pid) { bool is_merchant = false; Result merchant_categories(db->Select("SELECT * from merchant_item_categories where player_id=%u", pid.Unbox())); if (merchant_categories.IsValid()) { int i; int count=merchant_categories.Count(); for (i=0;i<count;i++) { psItemCategory * category = FindCategory(atoi(merchant_categories[i]["category_id"])); if (!category) { Error1("Error! Category could not be loaded. Skipping.\n"); continue; } categories.Push(category); is_merchant = true; } } return is_merchant; }
/* 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; }