void DBaseDecal::Spread (const FDecalTemplate *tpl, side_t *wall, double x, double y, double z, F3DFloor * ffloor) { FTexture *tex; vertex_t *v1; double rorg, ldx, ldy; GetWallStuff (wall, v1, ldx, ldy); rorg = Length (x - v1->fX(), y - v1->fY()); if ((tex = TexMan[PicNum]) == NULL) { return; } int dwidth = tex->GetWidth (); DecalWidth = dwidth * ScaleX; DecalLeft = tex->LeftOffset * ScaleX; DecalRight = DecalWidth - DecalLeft; SpreadSource = this; SpreadTemplate = tpl; SpreadZ = z; // Try spreading left first SpreadLeft (rorg - DecalLeft, v1, wall, ffloor); SpreadStack.Clear (); // Then try spreading right SpreadRight (rorg + DecalRight, wall, Length (wall->linedef->Delta().X, wall->linedef->Delta().Y), ffloor); SpreadStack.Clear (); }
void DBaseDecal::Spread (const FDecalTemplate *tpl, side_t *wall, fixed_t x, fixed_t y, fixed_t z, F3DFloor * ffloor) { FTexture *tex; vertex_t *v1; fixed_t rorg, ldx, ldy; GetWallStuff (wall, v1, ldx, ldy); rorg = Length (x - v1->x, y - v1->y); tex = TexMan[PicNum]; int dwidth = tex->GetWidth (); DecalWidth = dwidth * ScaleX; DecalLeft = tex->LeftOffset * ScaleX; DecalRight = DecalWidth - DecalLeft; SpreadSource = this; SpreadTemplate = tpl; SpreadZ = z; // Try spreading left first SpreadLeft (rorg - DecalLeft, v1, wall, ffloor); SpreadStack.Clear (); // Then try spreading right SpreadRight (rorg + DecalRight, wall, Length (wall->linedef->dx, wall->linedef->dy), ffloor); SpreadStack.Clear (); }
void gl_InitializeActorLights() { for(unsigned int i=0;i<LightAssociations.Size();i++) { const PClass * ti = PClass::FindClass(LightAssociations[i].ActorName()); if (ti) { ti = GetRealType(ti); AActor * defaults = GetDefaultByType(ti); if (defaults) { FInternalLightAssociation * iasso = new FInternalLightAssociation(&LightAssociations[i]); if (!defaults->lightassociations) { TDeletingArray<FInternalLightAssociation*> *p =new TDeletingArray<FInternalLightAssociation*>; defaults->lightassociations = p; AssoDeleter.Push(p); } TDeletingArray<FInternalLightAssociation *> * lights = gl_GetActorLights(defaults); if (iasso->Light()==NULL) { // The definition was not valid. delete iasso; } else { lights->Push(iasso); } } } } // we don't need the parser data for the light associations anymore LightAssociations.Clear(); LightAssociations.ShrinkToFit(); StateLights.Resize(ParsedStateLights.Size()+1); for(unsigned i=0; i<ParsedStateLights.Size();i++) { if (ParsedStateLights[i] != NAME_None) { StateLights[i] = (FLightDefaults*)-1; // something invalid that's not NULL. for(unsigned int j=0;j<LightDefaults.Size();j++) { if (LightDefaults[j]->GetName() == ParsedStateLights[i]) { StateLights[i] = LightDefaults[j]; break; } } } else StateLights[i] = NULL; } StateLights[StateLights.Size()-1] = NULL; // terminator ParsedStateLights.Clear(); ParsedStateLights.ShrinkToFit(); }
void ShutdownMapInfo() { guard(ShutdownMapInfo); DefaultMap.Name.Clean(); MapInfo.Clear(); MapSongList.Clear(); ClusterDefs.Clear(); EpisodeDefs.Clear(); SkillDefs.Clear(); unguard; }
void R_DeinitColormaps () { SpecialColormaps.Clear(); fakecmaps.Clear(); if (realcolormaps != NULL) { delete[] realcolormaps; realcolormaps = NULL; } FreeSpecialLights(); }
void gl_CreateSections() { SectionLines.Clear(); SectionLoops.Clear(); Sections.Clear(); SectionForSubsector.Resize(numsubsectors); memset(&SectionForSubsector[0], -1, numsubsectors * sizeof(SectionForSubsector[0])); FSectionCreator creat; creat.CreateSections(); if (dumpsections) DumpSections(); }
void gl_ReleaseLights() { unsigned int i; for (i = 0; i < LightDefaults.Size(); i++) { delete LightDefaults[i]; } LightAssociations.Clear(); LightDefaults.Clear(); }
static void ParseMapInfo(VScriptParser* sc) { guard(ParseMapInfo); bool HexenMode = false; // Set up default map info. mapInfo_t Default; SetMapDefaults(Default); while (!sc->AtEnd()) { if (sc->Check("map")) { ParseMap(sc, HexenMode, Default); } else if (sc->Check("defaultmap")) { SetMapDefaults(Default); ParseMapCommon(sc, &Default, HexenMode); } else if (sc->Check("adddefaultmap")) { ParseMapCommon(sc, &Default, HexenMode); } else if (sc->Check("clusterdef")) { ParseClusterDef(sc); } else if (sc->Check("episode")) { ParseEpisodeDef(sc); } else if (sc->Check("clearepisodes")) { EpisodeDefs.Clear(); } else if (sc->Check("skill")) { ParseSkillDef(sc); } else if (sc->Check("clearskills")) { SkillDefs.Clear(); } else { sc->Error(va("Invalid command %s", *sc->String)); } } delete sc; sc = NULL; unguard; }
void P_SetupWeapons_ntohton() { unsigned int i; const PClass *cls; Weapons_ntoh.Clear(); Weapons_hton.Clear(); cls = NULL; Weapons_ntoh.Push(cls); // Index 0 is always NULL. for (i = 0; i < PClass::m_Types.Size(); ++i) { PClass *cls = PClass::m_Types[i]; if (cls->ActorInfo != NULL && cls->IsDescendantOf(RUNTIME_CLASS(AWeapon))) { Weapons_ntoh.Push(cls); } } qsort(&Weapons_ntoh[1], Weapons_ntoh.Size() - 1, sizeof(Weapons_ntoh[0]), ntoh_cmp); for (i = 0; i < Weapons_ntoh.Size(); ++i) { Weapons_hton[Weapons_ntoh[i]] = i; } }
void FTeam::ParseTeamInfo () { int iLump, iLastLump = 0; Teams.Clear(); while ((iLump = Wads.FindLump ("TEAMINFO", &iLastLump)) != -1) { FScanner Scan (iLump); while (Scan.GetString ()) { if (Scan.Compare ("ClearTeams")) ClearTeams (); else if (Scan.Compare ("Team")) ParseTeamDefinition (Scan); else Scan.ScriptError ("ParseTeamInfo: Unknown team command '%s'.\n", Scan.String); } } if (Teams.Size () < 2) I_FatalError ("ParseTeamInfo: At least two teams must be defined in TEAMINFO."); else if (Teams.Size () > (unsigned)TEAM_MAXIMUM) I_FatalError ("ParseTeamInfo: Too many teams defined. (Maximum: %d)", TEAM_MAXIMUM); }
//========================================================================== // // // //========================================================================== SortNode * HWDrawList::SortSpriteList(SortNode * head) { SortNode * n; int count; unsigned i; static TArray<SortNode*> sortspritelist; SortNode * parent=head->parent; sortspritelist.Clear(); for(count=0,n=head;n;n=n->next) sortspritelist.Push(n); std::stable_sort(sortspritelist.begin(), sortspritelist.end(), [=](SortNode *a, SortNode *b) { return CompareSprites(a, b) < 0; }); for(i=0;i<sortspritelist.Size();i++) { sortspritelist[i]->next=NULL; if (parent) parent->equal=sortspritelist[i]; parent=sortspritelist[i]; } return sortspritelist[0]; }
void P_SetupWeapons_ntohton() { unsigned int i; PClassWeapon *cls; Weapons_ntoh.Clear(); Weapons_hton.Clear(); cls = NULL; Weapons_ntoh.Push(cls); // Index 0 is always NULL. for (i = 0; i < PClassActor::AllActorClasses.Size(); ++i) { PClassActor *cls = PClassActor::AllActorClasses[i]; if (cls->IsDescendantOf(RUNTIME_CLASS(AWeapon))) { Weapons_ntoh.Push(static_cast<PClassWeapon *>(cls)); } } qsort(&Weapons_ntoh[1], Weapons_ntoh.Size() - 1, sizeof(Weapons_ntoh[0]), ntoh_cmp); for (i = 0; i < Weapons_ntoh.Size(); ++i) { Weapons_hton[Weapons_ntoh[i]] = i; } }
static void ParseStatistics(const char *fn, TArray<FStatistics> &statlist) { statlist.Clear(); try { FScanner sc; sc.OpenFile(fn); while (sc.GetString()) { FStatistics &ep_entry = statlist[statlist.Reserve(1)]; ep_entry.epi_header = sc.String; sc.MustGetString(); ep_entry.epi_name = sc.String; sc.MustGetStringName("{"); while (!sc.CheckString("}")) { FSessionStatistics &session = ep_entry.stats[ep_entry.stats.Reserve(1)]; sc.MustGetString(); sc.MustGetString(); strncpy(session.name, sc.String, 12); sc.MustGetString(); strncpy(session.info, sc.String, 30); int h,m,s; sc.MustGetString(); sscanf(sc.String, "%d:%d:%d", &h, &m, &s); session.timeneeded= ((((h*60)+m)*60)+s)*TICRATE; sc.MustGetNumber(); session.skill=sc.Number; if (sc.CheckString("{")) { while (!sc.CheckString("}")) { FLevelStatistics &lstats = session.levelstats[session.levelstats.Reserve(1)]; sc.MustGetString(); strncpy(lstats.name, sc.String, 12); sc.MustGetString(); strncpy(lstats.info, sc.String, 30); int h,m,s; sc.MustGetString(); sscanf(sc.String, "%d:%d:%d", &h, &m, &s); lstats.timeneeded= ((((h*60)+m)*60)+s)*TICRATE; lstats.skill = 0; } } } } } catch(CRecoverableError &) { } }
void I_FlushBufferedConsoleStuff() { for (unsigned i = 0; i < bufferedConsoleStuff.Size(); i++) { DoPrintStr(bufferedConsoleStuff[i], ConWindow, NULL); } bufferedConsoleStuff.Clear(); }
void FL_Shutdown() { guard(FL_Shutdown); for (int i = 0; i < SearchPaths.Num(); i++) { delete SearchPaths[i]; SearchPaths[i] = NULL; } SearchPaths.Clear(); fl_basedir.Clean(); fl_savedir.Clean(); fl_gamedir.Clean(); fl_mainwad.Clean(); wadfiles.Clear(); IWadDirs.Clear(); unguard; }
void FTextureManager::AddHiresTextures (int wadnum) { int firsttx = Wads.GetFirstLump(wadnum); int lasttx = Wads.GetLastLump(wadnum); char name[9]; TArray<FTextureID> tlist; if (firsttx == -1 || lasttx == -1) { return; } name[8] = 0; for (;firsttx <= lasttx; ++firsttx) { if (Wads.GetLumpNamespace(firsttx) == ns_hires) { Wads.GetLumpName (name, firsttx); if (Wads.CheckNumForName (name, ns_hires) == firsttx) { tlist.Clear(); int amount = ListTextures(name, tlist); if (amount == 0) { // A texture with this name does not yet exist FTexture * newtex = FTexture::CreateTexture (firsttx, FTexture::TEX_Any); if (newtex != NULL) { newtex->UseType=FTexture::TEX_Override; AddTexture(newtex); } } else { for(unsigned int i = 0; i < tlist.Size(); i++) { FTexture * newtex = FTexture::CreateTexture (firsttx, FTexture::TEX_Any); if (newtex != NULL) { FTexture * oldtex = Textures[tlist[i].GetIndex()].Texture; // Replace the entire texture and adjust the scaling and offset factors. newtex->bWorldPanning = true; newtex->SetScaledSize(oldtex->GetScaledWidth(), oldtex->GetScaledHeight()); newtex->LeftOffset = FixedMul(oldtex->GetScaledLeftOffset(), newtex->xScale); newtex->TopOffset = FixedMul(oldtex->GetScaledTopOffset(), newtex->yScale); ReplaceTexture(tlist[i], newtex, true); } } } //StartScreen->Progress(); } } } }
void gl_InitPortals() { FPortalMap collection; if (numnodes == 0) return; for(int i=0;i<numnodes;i++) { node_t *no = &nodes[i]; double fdx = (double)no->dx; double fdy = (double)no->dy; no->len = (float)sqrt(fdx * fdx + fdy * fdy); } CollectPortalSectors(collection); portals.Clear(); FPortalMap::Iterator it(collection); FPortalMap::Pair *pair; int c = 0; int planeflags = 0; while (it.NextPair(pair)) { for(unsigned i=0;i<pair->Value.Size(); i++) { if (pair->Value[i].mPlane == sector_t::floor) planeflags |= 1; else if (pair->Value[i].mPlane == sector_t::ceiling) planeflags |= 2; } for (int i=1;i<=2;i<<=1) { // For now, add separate portals for floor and ceiling. They can be merged once // proper plane clipping is in. if (planeflags & i) { FPortal *portal = new FPortal; portal->xDisplacement = pair->Key.mXDisplacement; portal->yDisplacement = pair->Key.mYDisplacement; portal->plane = (i==1? sector_t::floor : sector_t::ceiling); /**/ portal->glportal = NULL; portals.Push(portal); for(unsigned j=0;j<pair->Value.Size(); j++) { sector_t *sec = pair->Value[j].mSub; int plane = pair->Value[j].mPlane; if (portal->plane == plane) { for(int k=0;k<sec->subsectorcount; k++) { subsector_t *sub = sec->subsectors[k]; gl_BuildPortalCoverage(&sub->portalcoverage[plane], sub, portal); } sec->portals[plane] = portal; } } } } } }
int FinishStates (FActorInfo *actor, AActor *defaults, Baggage &bag) { static int c=0; int count = StateArray.Size(); if (count > 0) { FState *realstates = new FState[count]; int i; int currange; memcpy(realstates, &StateArray[0], count*sizeof(FState)); actor->OwnedStates = realstates; actor->NumOwnedStates = count; // adjust the state pointers // In the case new states are added these must be adjusted, too! FixStatePointers (actor, StateLabels); for(i = currange = 0; i < count; i++) { // resolve labels and jumps switch((ptrdiff_t)realstates[i].NextState) { case 0: // next realstates[i].NextState = (i < count-1 ? &realstates[i+1] : &realstates[0]); break; case -1: // stop realstates[i].NextState = NULL; break; case -2: // wait realstates[i].NextState = &realstates[i]; break; default: // loop if ((size_t)realstates[i].NextState < 0x10000) { realstates[i].NextState = &realstates[(size_t)realstates[i].NextState-1]; } else // goto { realstates[i].NextState = ResolveGotoLabel (defaults, bag.Info->Class, (char *)realstates[i].NextState); } } } } StateArray.Clear (); // Fix state pointers that are gotos FixStatePointersAgain (actor, defaults, StateLabels); return count; }
// // R_ClearDrawSegs // void R_ClearDrawSegs (void) { if (drawsegs == NULL) { MaxDrawSegs = 256; // [RH] Default. Increased as needed. firstdrawseg = drawsegs = (drawseg_t *)M_Malloc (MaxDrawSegs * sizeof(drawseg_t)); } FirstInterestingDrawseg = 0; InterestingDrawsegs.Clear (); ds_p = drawsegs; }
void P_InitTerrainTypes () { int lastlump; int lump; int size; Splashes.Clear(); Terrains.Clear(); size = (TexMan.NumTextures()+1); TerrainTypes.Resize(size); TerrainTypes.Clear(); MakeDefaultTerrain (); lastlump = 0; while (-1 != (lump = Wads.FindLump ("TERRAIN", &lastlump)) ) { FScanner sc(lump); ParseOuter (sc); } Splashes.ShrinkToFit (); Terrains.ShrinkToFit (); }
static void G_SerializeHub(FArchive & arc) { int i=hubdata.Size(); arc << i; if (i>0) { if (arc.IsStoring()) arc.Write(&hubdata[0], i * sizeof(wbstartstruct_t)); else { hubdata.Resize(i); arc.Read(&hubdata[0], i * sizeof(wbstartstruct_t)); } } else hubdata.Clear(); }
void STAT_StartNewGame(const char *mapname) { LevelData.Clear(); if (!deathmatch && !multiplayer) { for(unsigned int j=0;j<AllEpisodes.Size();j++) { if (!AllEpisodes[j].mEpisodeMap.CompareNoCase(mapname)) { StartEpisode = &AllEpisodes[j]; return; } } } StartEpisode = NULL; }
void R_DeinitTranslationTables() { for (int i = 0; i < NUM_TRANSLATION_TABLES; ++i) { for (unsigned int j = 0; j < translationtables[i].Size(); ++j) { if (translationtables[i][j] != NULL) { delete translationtables[i][j]; translationtables[i][j] = NULL; } } translationtables[i].Clear(); } BloodTranslationColors.Clear(); }
static void MakeStateList(const FStateLabels *list, TArray<FStateDefine> &dest) { dest.Clear(); if (list != NULL) for(int i=0;i<list->NumLabels;i++) { FStateDefine def; def.Label = list->Labels[i].Label; def.State = list->Labels[i].State; dest.Push(def); if (list->Labels[i].Children != NULL) { MakeStateList(list->Labels[i].Children, dest[dest.Size()-1].Children); } } }
void C_BackupCVars (void) { assert(CVarBackups.Size() == 0); CVarBackups.Clear(); FCVarBackup backup; for (FBaseCVar *cvar = CVars; cvar != NULL; cvar = cvar->m_Next) { if ((cvar->Flags & (CVAR_SERVERINFO|CVAR_DEMOSAVE)) && !(cvar->Flags & CVAR_LATCH)) { backup.Name = cvar->GetName(); backup.String = cvar->GetGenericRep(CVAR_String).String; CVarBackups.Push(backup); } } }
void SkylineBinPack::Insert(TArray<RectSize> &rects, TArray<Rect> &dst) { dst.Clear(); while(rects.Size() > 0) { Rect bestNode; int bestScore1 = INT_MAX; int bestScore2 = INT_MAX; int bestSkylineIndex = -1; int bestRectIndex = -1; for(unsigned i = 0; i < rects.Size(); ++i) { Rect newNode; int score1; int score2; int index; newNode = FindPositionForNewNodeMinWaste(rects[i].width, rects[i].height, score2, score1, index); assert(disjointRects.Disjoint(newNode)); if (newNode.height != 0) { if (score1 < bestScore1 || (score1 == bestScore1 && score2 < bestScore2)) { bestNode = newNode; bestScore1 = score1; bestScore2 = score2; bestSkylineIndex = index; bestRectIndex = i; } } } if (bestRectIndex == -1) return; // Perform the actual packing. assert(disjointRects.Disjoint(bestNode)); #ifdef _DEBUG disjointRects.Add(bestNode); #endif AddSkylineLevel(bestSkylineIndex, bestNode); usedSurfaceArea += rects[bestRectIndex].width * rects[bestRectIndex].height; rects.Delete(bestRectIndex); dst.Push(bestNode); } }
TArray<FName> &MakeStateNameList(const char * fname) { static TArray<FName> namelist(3); FName firstpart, secondpart; char *c; // Handle the old names for the existing death states char *name = copystring(fname); firstpart = strtok(name, "."); switch (firstpart) { case NAME_Burn: firstpart = NAME_Death; secondpart = NAME_Fire; break; case NAME_Ice: firstpart = NAME_Death; secondpart = NAME_Ice; break; case NAME_Disintegrate: firstpart = NAME_Death; secondpart = NAME_Disintegrate; break; case NAME_XDeath: firstpart = NAME_Death; secondpart = NAME_Extreme; break; } namelist.Clear(); namelist.Push(firstpart); if (secondpart != NAME_None) { namelist.Push(secondpart); } while ((c = strtok(NULL, ".")) != NULL) { FName cc = c; namelist.Push(cc); } delete[] name; return namelist; }
static FxExpression *ParseRandomPick(FScanner &sc, FName identifier, PClassActor *cls) { bool floaty = identifier == NAME_FRandomPick; FRandom *rng; TArray<FxExpression*> list; list.Clear(); int index = 0; rng = ParseRNG(sc); sc.MustGetToken('('); for (;;) { FxExpression *expr = ParseExpressionM(sc, cls); list.Push(expr); if (sc.CheckToken(')')) break; sc.MustGetToken(','); } return new FxRandomPick(rng, list, floaty, sc); }
//========================================================================== // // // //========================================================================== SortNode * GLDrawList::SortSpriteList(SortNode * head) { SortNode * n; int count; unsigned i; static TArray<SortNode*> sortspritelist; SortNode * parent=head->parent; sortspritelist.Clear(); for(count=0,n=head;n;n=n->next) sortspritelist.Push(n); gd=this; qsort(&sortspritelist[0],sortspritelist.Size(),sizeof(SortNode *),CompareSprite); for(i=0;i<sortspritelist.Size();i++) { sortspritelist[i]->next=NULL; if (parent) parent->equal=sortspritelist[i]; parent=sortspritelist[i]; } return sortspritelist[0]; }
void MapLoader::IterFindPolySides (FPolyObj *po, side_t *side) { static TArray<uint32_t> vnum; unsigned int vnumat; assert(sidetemp.Size() > 0); vnum.Clear(); vnum.Push(uint32_t(Index(side->V1()))); vnumat = 0; while (vnum.Size() != vnumat) { uint32_t sidenum = sidetemp[vnum[vnumat++]].b.first; while (sidenum != NO_SIDE) { po->Sidedefs.Push(&Level->sides[sidenum]); AddPolyVert(vnum, uint32_t(Index(Level->sides[sidenum].V2()))); sidenum = sidetemp[sidenum].b.next; } } }