void Cmd_LoadNodes_f (edict_t *ent) { if (!ent->myskills.administrator) return; LoadGrid(); safe_cprintf(ent, PRINT_HIGH, "Loading nodes...\n", numnodes); }
BOOL CFunctionList::OnInitDialog() { CDialog::OnInitDialog(); LoadState(); m_Sort.SetCheck(nPrevSort); #ifdef MYDEBUG m_Grid.SetDoubleBuffering(0); #else m_Grid.SetDoubleBuffering(1); #endif m_Grid.SetImageList(GetImageList()); //начальные параметры таблицы m_Grid.EnableDragAndDrop(false); m_Grid.SetGridLineColor(RGB(255,255,255)); m_Grid.SetFixedColumnSelection(1); m_Grid.SetFixedRowSelection(1); m_Grid.SetHeaderSort(1); m_Grid.SetDefCellHeight(16); m_Grid.SetDefCellWidth(210); m_Grid.SetSingleRowSelection(1); m_Grid.SetListMode(1); m_Grid.AutoSizeColumns(1); m_Grid.SetGridBkColor(RGB(255,255,255)); m_Grid.m_NotUseMyExtEdit=TRUE; m_Grid.SetRowCount(1+aListName.GetSize()); m_Grid.SetColumnCount(1); m_Grid.SetFixedRowCount(1); m_Grid.SetFixedColumnCount(0); m_Grid.SetEditable(0); LoadGrid(); if(nLine<0) nLine=0; m_Grid.SetCurrentCell(nLine+1,0); SortGrid(); //поиск текущей строки в таблице int nRow=GetNumberInGrid(nLine); if(nRow<1) nRow=1; m_Grid.SetCurrentCell(nRow,0); return FALSE; }
// DataIO_OpenDx::ReadData() int DataIO_OpenDx::ReadData(FileName const& fname, DataSetList& datasetlist, std::string const& dsname) { // Add grid data set. Default to float for now. DataSet* ds = datasetlist.AddSet( DataSet::GRID_FLT, dsname, "GRID" ); if (ds==0) return 1; if (LoadGrid(fname.full(), *ds)) { // Load failed. Erase grid data set. datasetlist.RemoveSet( ds ); return 1; } return 0; }
/* Main window procedure */ static LRESULT CALLBACK win_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) { case WM_SIZE: /* Resize the grid control so it takes all space of the top * level window */ if(wParam == SIZE_RESTORED || wParam == SIZE_MAXIMIZED) SetWindowPos(hwndGrid, NULL, 5, 5, LOWORD(lParam)-10, HIWORD(lParam)-10, SWP_NOZORDER); return 0; case WM_SETFOCUS: SetFocus(hwndGrid); return 0; case WM_SETFONT: { MC_GGEOMETRY geom; SendMessage(hwndGrid, WM_SETFONT, wParam, lParam); /* Reset grid's geometry to defaults according to the font. */ SendMessage(hwndGrid, MC_GM_SETGEOMETRY, 0, 0); /* Make it to use a bit more space. */ geom.fMask = MC_GGF_ROWHEADERWIDTH | MC_GGF_COLUMNWIDTH; SendMessage(hwndGrid, MC_GM_GETGEOMETRY, 0, (LPARAM)&geom); geom.wRowHeaderWidth = 50; geom.wColumnWidth += geom.wColumnWidth / 2; SendMessage(hwndGrid, MC_GM_SETGEOMETRY, 0, (LPARAM)&geom); return 0; } case WM_CREATE: /* Create grid control and fill it with some data */ hwndGrid = CreateWindowEx(WS_EX_CLIENTEDGE, MC_WC_GRID, _T(""), WS_CHILD | WS_VISIBLE | WS_TABSTOP | MC_GS_COLUMNHEADERALPHABETIC | MC_GS_ROWHEADERCUSTOM, 0, 0, 0, 0, hwnd, (HMENU) IDC_GRID, hInst, NULL); LoadGrid(); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hwnd, uMsg, wParam, lParam); }
void CFunctionList::OnCheckSort() { CCellID curCell=m_Grid.GetFocusCell(); int nIndex=GetNumberInArray(curCell.row); nPrevSort=m_Sort.GetCheck(); if(nPrevSort) SortGrid(); else LoadGrid(); //поиск текущей строки в таблице int nRow=GetNumberInGrid(nIndex); if(nRow>0) m_Grid.SetCurrentCell(nRow,0); m_Grid.RedrawWindow(); }
int main( int , char * [] ) { double runTime = PerfTime(); LoadGrid(); LoadDic(); PrintBoard(); BoardValid(); LoadBoardState(); StashBoardState(); PrintBoard(); BoardValid(); double setupEnd = PerfTime(); // find all the seed points Coords seedPoints = GetSeedPoints(); logf( 1, CLEAR "Seed\n" ); for( auto i : seedPoints ) { logf( 1, CLEAR "%i,%i\n", i.x, i.y ); } // for each seed point: // find all words for that point, score them, from highest score down, validate them // return the highest seed point highest scoring word double checking = PerfTime(); int scoreBefore = BoardScore(); AddAndCheck( "voi", 3, 4, HORIZONTAL ); int scoreAfter = BoardScore(); logf( 1, CLEAR "Score diff = %i (%i -> %i)\n", scoreAfter - scoreBefore, scoreBefore, scoreAfter ); //PrintBoard(); BoardValid(); double done = PerfTime(); logf( 1, CLEAR "Timing (%f s) Loading\n", setupEnd - runTime ); //logf( 1, CLEAR "Timing (%f s) Preparing\n", prepared-prepping); logf( 1, CLEAR "Timing (%f s) running\n", done-checking ); return 0; }
bool Spawn2::Process() { _ZP(Spawn2_Process); IsDespawned = false; if(!Enabled()) return true; //grab our spawn group SpawnGroup* sg = zone->spawn_group_list.GetSpawnGroup(spawngroup_id_); if(NPCPointerValid() && (sg->despawn == 0 || condition_id != 0)) return true; if (timer.Check()) { timer.Disable(); _log(SPAWNS__MAIN, "Spawn2 %d: Timer has triggered", spawn2_id); //first check our spawn condition, if this isnt active //then we reset the timer and try again next time. if(condition_id != SC_AlwaysEnabled && !zone->spawn_conditions.Check(condition_id, condition_min_value)) { _log(SPAWNS__CONDITIONS, "Spawn2 %d: spawning prevented by spawn condition %d", spawn2_id, condition_id); Reset(); return(true); } if (sg == NULL) { database.LoadSpawnGroupsByID(spawngroup_id_,&zone->spawn_group_list); sg = zone->spawn_group_list.GetSpawnGroup(spawngroup_id_); } if (sg == NULL) { _log(SPAWNS__MAIN, "Spawn2 %d: Unable to locate spawn group %d. Disabling.", spawn2_id, spawngroup_id_); return false; } //have the spawn group pick an NPC for us uint32 npcid = sg->GetNPCType(); if (npcid == 0) { _log(SPAWNS__MAIN, "Spawn2 %d: Spawn group %d did not yeild an NPC! not spawning.", spawn2_id, spawngroup_id_); Reset(); //try again later (why?) return(true); } //try to find our NPC type. const NPCType* tmp = database.GetNPCType(npcid); if (tmp == NULL) { _log(SPAWNS__MAIN, "Spawn2 %d: Spawn group %d yeilded an invalid NPC type %d", spawn2_id, spawngroup_id_, npcid); Reset(); //try again later return(true); } if(tmp->unique_spawn_by_name) { if(!entity_list.LimitCheckName(tmp->name)) { _log(SPAWNS__MAIN, "Spawn2 %d: Spawn group %d yeilded NPC type %d, which is unique and one already exists.", spawn2_id, spawngroup_id_, npcid); timer.Start(5000); //try again in five seconds. return(true); } } if(tmp->spawn_limit > 0) { if(!entity_list.LimitCheckType(npcid, tmp->spawn_limit)) { _log(SPAWNS__MAIN, "Spawn2 %d: Spawn group %d yeilded NPC type %d, which is over its spawn limit (%d)", spawn2_id, spawngroup_id_, npcid, tmp->spawn_limit); timer.Start(5000); //try again in five seconds. return(true); } } if(sg->despawn != 0 && condition_id == 0) zone->Despawn(spawn2_id); if(IsDespawned) return true; if(spawn2_id) database.UpdateSpawn2Timeleft(spawn2_id, zone->GetInstanceID(), 0); currentnpcid = npcid; NPC* npc = new NPC(tmp, this, x, y, z, heading, FlyMode3); //DCBOOKMARK npc->mod_prespawn(this); npcthis = npc; npc->AddLootTable(); npc->SetSp2(spawngroup_id_); npc->SaveGuardPointAnim(anim); npc->SetAppearance((EmuAppearance)anim); entity_list.AddNPC(npc); //this limit add must be done after the AddNPC since we need the entity ID. entity_list.LimitAddNPC(npc); if(sg->roamdist && sg->roambox[0] && sg->roambox[1] && sg->roambox[2] && sg->roambox[3] && sg->delay) npc->AI_SetRoambox(sg->roamdist,sg->roambox[0],sg->roambox[1],sg->roambox[2],sg->roambox[3],sg->delay); if(zone->InstantGrids()) { _log(SPAWNS__MAIN, "Spawn2 %d: Group %d spawned %s (%d) at (%.3f, %.3f, %.3f).", spawn2_id, spawngroup_id_, npc->GetName(), npcid, x, y, z); LoadGrid(); } else { _log(SPAWNS__MAIN, "Spawn2 %d: Group %d spawned %s (%d) at (%.3f, %.3f, %.3f). Grid loading delayed.", spawn2_id, spawngroup_id_, tmp->name, npcid, x, y, z); } } return true; }
/* Main window procedure */ static LRESULT CALLBACK win_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) { case WM_NOTIFY: { /* Handle notifications from the grid control. */ NMHDR* hdr = (NMHDR*) lParam; if(hdr->idFrom == IDC_GRID && hdr->code == MC_GN_ENDLABELEDIT) { /* Accept the new text when user edits a cell label. Application * should implement this notification whenever it created the * grid control with the style MC_GS_EDITLABELS. */ return TRUE; } break; } case WM_SIZE: /* Resize the grid control so it takes all space of the top * level window */ if(wParam == SIZE_RESTORED || wParam == SIZE_MAXIMIZED) SetWindowPos(hwndGrid, NULL, 5, 5, LOWORD(lParam)-10, HIWORD(lParam)-10, SWP_NOZORDER); return 0; case WM_SETFOCUS: SetFocus(hwndGrid); return 0; case WM_SETFONT: { MC_GGEOMETRY geom; SendMessage(hwndGrid, WM_SETFONT, wParam, lParam); /* Reset grid's geometry to defaults according to the font. */ SendMessage(hwndGrid, MC_GM_SETGEOMETRY, 0, 0); /* Make it to use a bit more space. */ geom.fMask = MC_GGF_ROWHEADERWIDTH | MC_GGF_DEFCOLUMNWIDTH; SendMessage(hwndGrid, MC_GM_GETGEOMETRY, 0, (LPARAM)&geom); geom.wRowHeaderWidth = 50; geom.wDefColumnWidth += geom.wDefColumnWidth / 2; SendMessage(hwndGrid, MC_GM_SETGEOMETRY, 0, (LPARAM)&geom); return 0; } case WM_CREATE: /* Create grid control and fill it with some data */ hwndGrid = CreateWindowEx(WS_EX_CLIENTEDGE, MC_WC_GRID, _T(""), WS_CHILD | WS_VISIBLE | WS_TABSTOP | MC_GS_COLUMNHEADERALPHABETIC | MC_GS_ROWHEADERNORMAL | MC_GS_RESIZABLECOLUMNS | MC_GS_RESIZABLEROWS | MC_GS_FOCUSEDCELL | MC_GS_COMPLEXSEL | MC_GS_SHOWSELALWAYS | MC_GS_EDITLABELS, 0, 0, 0, 0, hwnd, (HMENU) IDC_GRID, hInst, NULL); LoadGrid(); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hwnd, uMsg, wParam, lParam); }
void CreateGrid (qboolean force) { // ====path stuff //int i; // ====path stuff int x,y,z,cnt=0; vec3_t v,endpt; trace_t tr1,tr2; float v0,v1,v2; vec3_t min1={0,0,0}; // width 6x6 vec3_t max1={0,0,0}; vec3_t min2={-16,-16,0};// width 32x32 (was 24x24) vec3_t max2={+16,+16,0}; numnodes=0; if (!force && LoadGrid()) return; for (x=0;x<maxx;x++) { v0=g2v0(x); // convert grid(x) to v[0] for (y=0;y<maxy;y++) { v1=g2v1(y); // convert grid(y) to v[1] for (z=maxz-1;z>=0;z--) { v2=g2v2(z); // convert grid(z) to v[2] //-------------------------------------- VectorSet(v,v0,v1,v2); // Skip world locations in solid/lava/slime/window/ladder if (gi.pointcontents(v) & MASK_OPAQUE) { z--; continue; } //----------------------------------------------- // At this point,v(x,y,z) is a point in mid-air //----------------------------------------------- // Trace small bbox down to see what is below VectorSet(endpt,v[0],v[1],-8192); // Stop at world locations in solid/lava/slime/window/ladder tr1=gi.trace(v,min1,max1,endpt,NULL,MASK_OPAQUE); // Set for-loop index to our endpt's grid(z) z=gridz(tr1.endpos[2]); // Skip if trace endpt hit func entity. if (tr1.ent && (tr1.ent->use || tr1.ent->think || tr1.ent->blocked)) continue; // Skip if trace endpt hit lava/slime/window/ladder. if (tr1.contents & (CONTENTS_LAVA|CONTENTS_SLIME|CONTENTS_WINDOW)) continue; // Skip if trace endpt hit non-walkable slope if (tr1.plane.normal[2]<0.7) continue; //---------------------------------------- // Test vertical clearance above v(x,y,z) //---------------------------------------- VectorCopy(tr1.endpos,endpt); //tr1.endpos[2]+=2; // set start just above surface endpt[2]+=32; // endpt at approx crouch height tr2=gi.trace(endpt,min2,max2,tr1.endpos,NULL,MASK_OPAQUE);//GHz - push down instead of up // Skip if not reachable by crouched bbox - trace incomplete? // if (tr2.fraction != 1.0) continue; // Skip if linewidth inside solid - too close to adjoining surface? if (tr2.startsolid || tr2.allsolid) continue; // GHz: check final position to see if it intersects with a solid tr1=gi.trace(tr2.endpos,min2,max2,tr2.endpos,NULL,MASK_OPAQUE); if (tr1.fraction != 1.0 || tr1.startsolid || tr1.allsolid) continue; if (!CheckBottom(tr2.endpos, min2, max2)) continue; VectorCopy(tr2.endpos, endpt);//GHz endpt[2]+=32;//GHz //if (tr2.allsolid) continue; //------------------------------------- // Now, adjust downward for uniformity //------------------------------------- // AdjustDownward(NULL,endpt); // Houston,we have a valid node! if (NearbyGridNode(endpt, cnt)) continue;//GHz VectorCopy(endpt,pathnode[cnt]); // copy to pathnode[] array cnt++; } } } numnodes=cnt; CullGrid(); gi.dprintf("%d Nodes Created\n",numnodes); //===================================================== //================== pathfinding stuff ================ //===================================================== /* // allocate memory for node array node = (node_t *) V_Malloc(numnodes*sizeof(node_t), TAG_LEVEL); // copy all the pathnode stuff to new node array for (i=0;i<numnodes;i++) { VectorCopy(pathnode[i], node[i].origin); node[i].nodenum = i; } */ if (!force) SaveGrid(); }
bool Spawn2::Process() { IsDespawned = false; if (!Enabled()) return true; //grab our spawn group SpawnGroup *spawn_group = zone->spawn_group_list.GetSpawnGroup(spawngroup_id_); if (NPCPointerValid() && (spawn_group->despawn == 0 || condition_id != 0)) { return true; } if (timer.Check()) { timer.Disable(); Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Timer has triggered", spawn2_id); //first check our spawn condition, if this isnt active //then we reset the timer and try again next time. if (condition_id != SC_AlwaysEnabled && !zone->spawn_conditions.Check(condition_id, condition_min_value)) { Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: spawning prevented by spawn condition %d", spawn2_id, condition_id); Reset(); return (true); } if (spawn_group == nullptr) { database.LoadSpawnGroupsByID(spawngroup_id_, &zone->spawn_group_list); spawn_group = zone->spawn_group_list.GetSpawnGroup(spawngroup_id_); } if (spawn_group == nullptr) { Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Unable to locate spawn group %d. Disabling.", spawn2_id, spawngroup_id_); return false; } //have the spawn group pick an NPC for us uint32 npcid = spawn_group->GetNPCType(); if (npcid == 0) { Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Spawn group %d did not yeild an NPC! not spawning.", spawn2_id, spawngroup_id_); Reset(); //try again later (why?) return (true); } //try to find our NPC type. const NPCType *tmp = database.LoadNPCTypesData(npcid); if (tmp == nullptr) { Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Spawn group %d yeilded an invalid NPC type %d", spawn2_id, spawngroup_id_, npcid); Reset(); //try again later return (true); } if (tmp->unique_spawn_by_name) { if (!entity_list.LimitCheckName(tmp->name)) { Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Spawn group %d yeilded NPC type %d, which is unique and one already exists.", spawn2_id, spawngroup_id_, npcid); timer.Start(5000); //try again in five seconds. return (true); } } if (tmp->spawn_limit > 0) { if (!entity_list.LimitCheckType(npcid, tmp->spawn_limit)) { Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Spawn group %d yeilded NPC type %d, which is over its spawn limit (%d)", spawn2_id, spawngroup_id_, npcid, tmp->spawn_limit); timer.Start(5000); //try again in five seconds. return (true); } } bool ignore_despawn = false; if (npcthis) { ignore_despawn = npcthis->IgnoreDespawn(); } if (ignore_despawn) { return true; } if (spawn_group->despawn != 0 && condition_id == 0 && !ignore_despawn) { zone->Despawn(spawn2_id); } if (IsDespawned) { return true; } currentnpcid = npcid; NPC *npc = new NPC(tmp, this, glm::vec4(x, y, z, heading), GravityBehavior::Water); npc->mod_prespawn(this); npcthis = npc; npc->AddLootTable(); if (npc->DropsGlobalLoot()) { npc->CheckGlobalLootTables(); } npc->SetSp2(spawngroup_id_); npc->SaveGuardPointAnim(anim); npc->SetAppearance((EmuAppearance) anim); entity_list.AddNPC(npc); //this limit add must be done after the AddNPC since we need the entity ID. entity_list.LimitAddNPC(npc); /** * Roambox init */ if (spawn_group->roamdist && spawn_group->roambox[0] && spawn_group->roambox[1] && spawn_group->roambox[2] && spawn_group->roambox[3] && spawn_group->delay && spawn_group->min_delay) { npc->AI_SetRoambox( spawn_group->roamdist, spawn_group->roambox[0], spawn_group->roambox[1], spawn_group->roambox[2], spawn_group->roambox[3], spawn_group->delay, spawn_group->min_delay ); } if (zone->InstantGrids()) { Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Group %d spawned %s (%d) at (%.3f, %.3f, %.3f).", spawn2_id, spawngroup_id_, npc->GetName(), npcid, x, y, z); LoadGrid(); } else { Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Group %d spawned %s (%d) at (%.3f, %.3f, %.3f). Grid loading delayed.", spawn2_id, spawngroup_id_, tmp->name, npcid, x, y, z); } } return true; }
bool LoadGridFromFile(Grid& grid, const char* filename, int procId) { return LoadGrid(grid, NULL, filename, aPosition, procId); }
bool LoadGridFromFile(Grid& grid, ISubsetHandler& sh, const char* filename, int procId) { return LoadGrid(grid, &sh, filename, aPosition, procId); }
bool Room::Load(File* f) { SetId(THE_ROOM_ID); // only one room exists at a time, with this fixed ID s_room = this; int numTextures = 0; if (!f->GetInteger(&numTextures)) { f->ReportError("Expected num textures."); return false; } m_texNames.reserve(numTextures); std::string s; for (int i = 0; i < numTextures; i++) { if (!f->GetDataLine(&s)) { f->ReportError("Expected texture name"); return false; } if (!TheResourceManager::Instance()->GetRes(s)) { f->ReportError("Not a valid texture name: " + s); return false; } m_texNames.push_back(s); } if (!LoadVec2(f, &m_gridsize)) { f->ReportError("Expected grid size"); return false; } for (int i = 0; i < NUM_TILE_MAPS; i++) { if (!LoadGrid(i, f)) { return false; } } // Load destination room numbers to NSEW if (!f->GetDataLine(&s)) { f->ReportError("Expected destination rooms"); return false; } Strings dests = Split(s, ','); if (dests.size() != 4) { f->ReportError("Expected FOUR comma-sep destination rooms"); return false; } bool nonz = false; for (int i = 0; i < 4; i++) { m_dest[i] = ToInt(dests[i]); if (m_dest[i]) { nonz = true; } } if (!nonz) { f->ReportError("Room has no destinations from it"); return false; } if (!f->GetDataLine(&m_music)) { f->ReportError("Room has no music"); return false; } // TODO TEMP //m_music = "sound/rainforest-ambience1.ogg"; std::cout << "Room music: " << m_music << "\n"; return true; }