コード例 #1
0
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();
}
コード例 #2
0
ファイル: thingdef_data.cpp プロジェクト: Krazygamr/D-Touch
void InitThingdef()
{
	// Sort the flag lists
	for (size_t i = 0; i < NUM_FLAG_LISTS; ++i)
	{
		qsort (FlagLists[i].Defs, FlagLists[i].NumDefs, sizeof(FFlagDef), flagcmp);
	}

	// Create a sorted list of properties
	if (properties.Size() == 0)
	{
		FAutoSegIterator probe(GRegHead, GRegTail);

		while (*++probe != NULL)
		{
			properties.Push((FPropertyInfo *)*probe);
		}
		properties.ShrinkToFit();
		qsort(&properties[0], properties.Size(), sizeof(properties[0]), propcmp);
	}

	// Create a sorted list of native action functions
	if (AFTable.Size() == 0)
	{
		FAutoSegIterator probe(ARegHead, ARegTail);

		while (*++probe != NULL)
		{
			AFTable.Push(*(AFuncDesc *)*probe);
		}
		AFTable.ShrinkToFit();
		qsort(&AFTable[0], AFTable.Size(), sizeof(AFTable[0]), funccmp);
	}

	// Create a sorted list of native variables
	if (variables.Size() == 0)
	{
		FAutoSegIterator probe(MRegHead, MRegTail);

		while (*++probe != NULL)
		{
			variables.Push((FVariableInfo *)*probe);
		}
		variables.ShrinkToFit();
		qsort(&variables[0], variables.Size(), sizeof(variables[0]), varcmp);
	}
}
コード例 #3
0
ファイル: p_terrain.cpp プロジェクト: doomtech/zdoom-old
void P_InitTerrainTypes ()
{
    int lastlump;
    int lump;
    int size;

    size = (TexMan.NumTextures()+1)*sizeof(byte);
    TerrainTypes = (byte *)Malloc (size);
    memset (TerrainTypes, 0, size);

    MakeDefaultTerrain ();

    lastlump = 0;
    while (-1 != (lump = Wads.FindLump ("TERRAIN", &lastlump)) )
    {
        SC_OpenLumpNum (lump, "TERRAIN");
        ParseOuter ();
        SC_Close ();
    }
    Splashes.ShrinkToFit ();
    Terrains.ShrinkToFit ();
}
コード例 #4
0
ファイル: p_terrain.cpp プロジェクト: ChillyDoom/zdoom
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 ();
}
コード例 #5
0
ファイル: c_cvars.cpp プロジェクト: WChrisK/Zandronum
void FilterCompactCVars (TArray<FBaseCVar *> &cvars, DWORD filter)
{
	FBaseCVar *cvar = CVars;
	while (cvar)
	{
		if ((cvar->Flags & filter) && !(cvar->Flags & CVAR_IGNORE))
			cvars.Push (cvar);
		cvar = cvar->m_Next;
	}
	if (cvars.Size () > 0)
	{
		cvars.ShrinkToFit ();
		qsort (&cvars[0], cvars.Size(), sizeof(FBaseCVar *), sortcvars);
	}
}
コード例 #6
0
ファイル: umapinfo.cpp プロジェクト: coelckers/gzdoom
// This will get called if after an UMAPINFO lump a regular (Z)MAPINFO is found or when MAPINFO parsing is complete.
void CommitUMapinfo(level_info_t *defaultinfo)
{
	for (auto &map : Maps)
	{
		auto levelinfo = FindLevelInfo(map.MapName);
		if (levelinfo == nullptr)
		{
			// Map did not exist yet.
			auto levelindex = wadlevelinfos.Reserve(1);
			levelinfo = &wadlevelinfos[levelindex];
			*levelinfo = *defaultinfo;
		}
		if (map.MapName.IsNotEmpty()) levelinfo->MapName = map.MapName;
		if (map.LevelName.IsNotEmpty())
		{
			levelinfo->LevelName = map.LevelName;
			levelinfo->PName = "";	// clear the map name patch to force the string version to be shown - unless explicitly overridden right next.
		}
		if (map.levelpic[0]) levelinfo->PName = map.levelpic;
		if (map.nextmap[0]) levelinfo->NextMap = map.nextmap;
		else if (map.endpic[0])
		{
			FName name = NAME_None;

			if (!stricmp(map.endpic, "$CAST"))
			{
				name = "INTER_CAST";
			}
			else if (!stricmp(map.endpic, "$BUNNY"))
			{
				name = "INTER_BUNNY";
			}
			else
			{
				name = MakeEndPic(map.endpic);
			}
			if (name != NAME_None)
			{
				levelinfo->NextMap.Format("enDSeQ%04x", int(name));
			}
		}

		if (map.nextsecret[0]) levelinfo->NextSecretMap = map.nextsecret;
		if (map.music[0])
		{
			levelinfo->Music = map.music;
			levelinfo->musicorder = 0;
		}
		if (map.skytexture[0])
		{
			levelinfo->SkyPic1 = map.skytexture;
			levelinfo->skyspeed1 = 0;
			levelinfo->SkyPic2 = "";
			levelinfo->skyspeed2 = 0;
		}
		if (map.partime > 0) levelinfo->partime = map.partime;
		if (map.enterpic[0]) levelinfo->EnterPic = map.enterpic;
		if (map.exitpic[0]) levelinfo->ExitPic = map.exitpic;
		if (map.intermusic[0])
		{
			levelinfo->InterMusic = map.intermusic;
			levelinfo->intermusicorder = 0;
		}
		if (map.BossActions.Size() > 0)
		{
			// Setting a boss action will deactivate the flag based monster actions.
			levelinfo->specialactions = std::move(map.BossActions);
			levelinfo->flags &= ~(LEVEL_BRUISERSPECIAL | LEVEL_CYBORGSPECIAL | LEVEL_SPIDERSPECIAL | LEVEL_MAP07SPECIAL | LEVEL_MINOTAURSPECIAL | LEVEL_HEADSPECIAL | LEVEL_SORCERER2SPECIAL | LEVEL_SPECACTIONSMASK | LEVEL_SPECKILLMONSTERS);
		}

		const int exflags = FExitText::DEF_TEXT | FExitText::DEF_BACKDROP | FExitText::DEF_MUSIC;
		if (map.InterText.IsNotEmpty())
		{
			if (map.InterText.Compare("-") != 0)
				levelinfo->ExitMapTexts[NAME_Normal] = { exflags, 0, map.InterText, map.interbackdrop, map.intermusic[0]? map.intermusic : gameinfo.intermissionMusic };
			else
				levelinfo->ExitMapTexts[NAME_Normal] = { 0, 0 };
		}
		if (map.InterTextSecret.IsNotEmpty())
		{
			if (map.InterTextSecret.Compare("-") != 0)
				levelinfo->ExitMapTexts[NAME_Secret] = { exflags, 0, map.InterTextSecret, map.interbackdrop, map.intermusic[0] ? map.intermusic : gameinfo.intermissionMusic };
			else
				levelinfo->ExitMapTexts[NAME_Secret] = { 0, 0 };
		}
		if (map.nointermission) levelinfo->flags |= LEVEL_NOINTERMISSION;
	}


	// All done. If we get here again, start fresh.
	Maps.Clear();
	Maps.ShrinkToFit();
}
コード例 #7
0
ファイル: thingdef_data.cpp プロジェクト: ezhangle/zdoom
void InitThingdef()
{
	// Sort the flag lists
	for (size_t i = 0; i < NUM_FLAG_LISTS; ++i)
	{
		qsort (FlagLists[i].Defs, FlagLists[i].NumDefs, sizeof(FFlagDef), flagcmp);
	}

	// Create a sorted list of properties
	if (properties.Size() == 0)
	{
		FAutoSegIterator probe(GRegHead, GRegTail);

		while (*++probe != NULL)
		{
			properties.Push((FPropertyInfo *)*probe);
		}
		properties.ShrinkToFit();
		qsort(&properties[0], properties.Size(), sizeof(properties[0]), propcmp);
	}

	// Create a sorted list of native action functions
	AFTable.Clear();
	if (AFTable.Size() == 0)
	{
		FAutoSegIterator probe(ARegHead, ARegTail);

		while (*++probe != NULL)
		{
			AFuncDesc *afunc = (AFuncDesc *)*probe;
			assert(afunc->VMPointer != NULL);
			*(afunc->VMPointer) = new VMNativeFunction(afunc->Function, afunc->Name);
			AFTable.Push(*afunc);
		}
		AFTable.ShrinkToFit();
		qsort(&AFTable[0], AFTable.Size(), sizeof(AFTable[0]), funccmp);
	}

	// Define some member variables we feel like exposing to the user
	PSymbolTable &symt = RUNTIME_CLASS(AActor)->Symbols;
	PType *array5 = NewArray(TypeSInt32, 5);
	symt.AddSymbol(new PField(NAME_Alpha,		TypeFloat64,	VARF_Native, myoffsetof(AActor,Alpha)));
	symt.AddSymbol(new PField(NAME_Angle,		TypeFloat64,	VARF_Native, myoffsetof(AActor,Angles.Yaw)));
	symt.AddSymbol(new PField(NAME_Args,		array5,			VARF_Native, myoffsetof(AActor,args)));
	symt.AddSymbol(new PField(NAME_CeilingZ,	TypeFloat64,	VARF_Native, myoffsetof(AActor,ceilingz)));
	symt.AddSymbol(new PField(NAME_FloorZ,		TypeFloat64,	VARF_Native, myoffsetof(AActor,floorz)));
	symt.AddSymbol(new PField(NAME_Health,		TypeSInt32,		VARF_Native, myoffsetof(AActor,health)));
	symt.AddSymbol(new PField(NAME_Mass,		TypeSInt32,		VARF_Native, myoffsetof(AActor,Mass)));
	symt.AddSymbol(new PField(NAME_Pitch,		TypeFloat64,	VARF_Native, myoffsetof(AActor,Angles.Pitch)));
	symt.AddSymbol(new PField(NAME_Roll,		TypeFloat64,	VARF_Native, myoffsetof(AActor,Angles.Roll)));
	symt.AddSymbol(new PField(NAME_Special,		TypeSInt32,		VARF_Native, myoffsetof(AActor,special)));
	symt.AddSymbol(new PField(NAME_TID,			TypeSInt32,		VARF_Native, myoffsetof(AActor,tid)));
	symt.AddSymbol(new PField(NAME_TIDtoHate,	TypeSInt32,		VARF_Native, myoffsetof(AActor,TIDtoHate)));
	symt.AddSymbol(new PField(NAME_WaterLevel,	TypeSInt32,		VARF_Native, myoffsetof(AActor,waterlevel)));
	symt.AddSymbol(new PField(NAME_X,			TypeFloat64,	VARF_Native, myoffsetof(AActor,__Pos.X)));	// must remain read-only!
	symt.AddSymbol(new PField(NAME_Y,			TypeFloat64,	VARF_Native, myoffsetof(AActor,__Pos.Y)));	// must remain read-only!
	symt.AddSymbol(new PField(NAME_Z,			TypeFloat64,	VARF_Native, myoffsetof(AActor,__Pos.Z)));	// must remain read-only!
	symt.AddSymbol(new PField(NAME_VelX,		TypeFloat64,	VARF_Native, myoffsetof(AActor,Vel.X)));
	symt.AddSymbol(new PField(NAME_VelY,		TypeFloat64,	VARF_Native, myoffsetof(AActor, Vel.Y)));
	symt.AddSymbol(new PField(NAME_VelZ,		TypeFloat64,	VARF_Native, myoffsetof(AActor, Vel.Z)));
	symt.AddSymbol(new PField(NAME_MomX,		TypeFloat64,	VARF_Native, myoffsetof(AActor, Vel.X)));
	symt.AddSymbol(new PField(NAME_MomY,		TypeFloat64,	VARF_Native, myoffsetof(AActor, Vel.Y)));
	symt.AddSymbol(new PField(NAME_MomZ,		TypeFloat64,	VARF_Native, myoffsetof(AActor, Vel.Z)));
	symt.AddSymbol(new PField(NAME_ScaleX,		TypeFloat64,	VARF_Native, myoffsetof(AActor, Scale.X)));
	symt.AddSymbol(new PField(NAME_ScaleY,		TypeFloat64,	VARF_Native, myoffsetof(AActor, Scale.Y)));
	symt.AddSymbol(new PField(NAME_Score,		TypeSInt32,		VARF_Native, myoffsetof(AActor,Score)));
	symt.AddSymbol(new PField(NAME_Accuracy,	TypeSInt32,		VARF_Native, myoffsetof(AActor,accuracy)));
	symt.AddSymbol(new PField(NAME_Stamina,		TypeSInt32,		VARF_Native, myoffsetof(AActor,stamina)));
	symt.AddSymbol(new PField(NAME_Height,		TypeFloat64,	VARF_Native, myoffsetof(AActor,Height)));
	symt.AddSymbol(new PField(NAME_Radius,		TypeFloat64,	VARF_Native, myoffsetof(AActor,radius)));
	symt.AddSymbol(new PField(NAME_ReactionTime,TypeSInt32,		VARF_Native, myoffsetof(AActor,reactiontime)));
	symt.AddSymbol(new PField(NAME_MeleeRange,	TypeFloat64,	VARF_Native, myoffsetof(AActor,meleerange)));
	symt.AddSymbol(new PField(NAME_Speed,		TypeFloat64,	VARF_Native, myoffsetof(AActor,Speed)));
	symt.AddSymbol(new PField(NAME_Threshold,	TypeSInt32,		VARF_Native, myoffsetof(AActor,threshold)));
	symt.AddSymbol(new PField(NAME_DefThreshold,TypeSInt32,		VARF_Native, myoffsetof(AActor,DefThreshold)));
}
コード例 #8
0
ファイル: thingdef_data.cpp プロジェクト: dwing4g/gzdoom
void InitThingdef()
{
	PType *TypeActor = NewPointer(RUNTIME_CLASS(AActor));

	PStruct *sstruct = NewNativeStruct("Sector", nullptr);
	auto sptr = NewPointer(sstruct);
	sstruct->AddNativeField("soundtarget", TypeActor, myoffsetof(sector_t, SoundTarget));
	
	// expose the global validcount variable.
	PField *vcf = new PField("validcount", TypeSInt32, VARF_Native | VARF_Static, (intptr_t)&validcount);
	GlobalSymbols.AddSymbol(vcf);

	// expose the global Multiplayer variable.
	PField *multif = new PField("multiplayer", TypeBool, VARF_Native | VARF_ReadOnly | VARF_Static, (intptr_t)&multiplayer);
	GlobalSymbols.AddSymbol(multif);

	// set up a variable for the global level data structure
	PStruct *lstruct = NewNativeStruct("LevelLocals", nullptr);
	PField *levelf = new PField("level", lstruct, VARF_Native | VARF_Static, (intptr_t)&level);
	GlobalSymbols.AddSymbol(levelf);

	// set up a variable for the DEH data
	PStruct *dstruct = NewNativeStruct("DehInfo", nullptr);
	PField *dehf = new PField("deh", dstruct, VARF_Native | VARF_Static, (intptr_t)&deh);

	GlobalSymbols.AddSymbol(dehf);

	// set up a variable for the global players array.
	PStruct *pstruct = NewNativeStruct("PlayerInfo", nullptr);
	pstruct->Size = sizeof(player_t);
	pstruct->Align = alignof(player_t);
	PArray *parray = NewArray(pstruct, MAXPLAYERS);
	PField *playerf = new PField("players", parray, VARF_Native | VARF_Static, (intptr_t)&players);
	GlobalSymbols.AddSymbol(playerf);

	// set up the lines array in the sector struct. This is a bit messy because the type system is not prepared to handle a pointer to an array of pointers to a native struct even remotely well...
	// As a result, the size has to be set to something large and arbritrary because it can change between maps. This will need some serious improvement when things get cleaned up.
	pstruct = NewNativeStruct("Sector", nullptr);
	pstruct->AddNativeField("lines", NewPointer(NewArray(NewPointer(NewNativeStruct("line", nullptr), false), 0x40000), false), myoffsetof(sector_t, lines), VARF_Native);

	parray = NewArray(TypeBool, MAXPLAYERS);
	playerf = new PField("playeringame", parray, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&playeringame);
	GlobalSymbols.AddSymbol(playerf);

	playerf = new PField("gameaction", TypeUInt8, VARF_Native | VARF_Static, (intptr_t)&gameaction);
	GlobalSymbols.AddSymbol(playerf);

	playerf = new PField("consoleplayer", TypeSInt32, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&consoleplayer);
	GlobalSymbols.AddSymbol(playerf);

	// Argh. It sucks when bad hacks need to be supported. WP_NOCHANGE is just a bogus pointer but it used everywhere as a special flag.
	// It cannot be defined as constant because constants can either be numbers or strings but nothing else, so the only 'solution'
	// is to create a static variable from it and reference that in the script. Yuck!!!
	static AWeapon *wpnochg = WP_NOCHANGE;
	playerf = new PField("WP_NOCHANGE", NewPointer(RUNTIME_CLASS(AWeapon), false), VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&wpnochg);
	GlobalSymbols.AddSymbol(playerf);

	// this needs to be done manually until it can be given a proper type.
	RUNTIME_CLASS(AActor)->AddNativeField("DecalGenerator", NewPointer(TypeVoid), myoffsetof(AActor, DecalGenerator));

	// synthesize a symbol for each flag from the flag name tables to avoid redundant declaration of them.
	for (auto &fl : FlagLists)
	{
		if (fl.Use & 2)
		{
			for(int i=0;i<fl.NumDefs;i++)
			{
				if (fl.Defs[i].structoffset > 0) // skip the deprecated entries in this list
				{
					const_cast<PClass*>(*fl.Type)->AddNativeField(FStringf("b%s", fl.Defs[i].name), (fl.Defs[i].fieldsize == 4 ? TypeSInt32 : TypeSInt16), fl.Defs[i].structoffset, fl.Defs[i].varflags, fl.Defs[i].flagbit);
				}
			}
		}
	}

	FAutoSegIterator probe(CRegHead, CRegTail);

	while (*++probe != NULL)
	{
		if (((ClassReg *)*probe)->InitNatives)
			((ClassReg *)*probe)->InitNatives();
	}

	// Sort the flag lists
	for (size_t i = 0; i < NUM_FLAG_LISTS; ++i)
	{
		qsort (FlagLists[i].Defs, FlagLists[i].NumDefs, sizeof(FFlagDef), flagcmp);
	}

	// Create a sorted list of properties
	if (properties.Size() == 0)
	{
		FAutoSegIterator probe(GRegHead, GRegTail);

		while (*++probe != NULL)
		{
			properties.Push((FPropertyInfo *)*probe);
		}
		properties.ShrinkToFit();
		qsort(&properties[0], properties.Size(), sizeof(properties[0]), propcmp);
	}

	// Create a sorted list of native action functions
	AFTable.Clear();
	if (AFTable.Size() == 0)
	{
		FAutoSegIterator probe(ARegHead, ARegTail);

		while (*++probe != NULL)
		{
			AFuncDesc *afunc = (AFuncDesc *)*probe;
			assert(afunc->VMPointer != NULL);
			*(afunc->VMPointer) = new VMNativeFunction(afunc->Function, afunc->FuncName);
			(*(afunc->VMPointer))->PrintableName.Format("%s.%s [Native]", afunc->ClassName+1, afunc->FuncName);
			AFTable.Push(*afunc);
		}
		AFTable.ShrinkToFit();
		qsort(&AFTable[0], AFTable.Size(), sizeof(AFTable[0]), funccmp);
	}

	FieldTable.Clear();
	if (FieldTable.Size() == 0)
	{
		FAutoSegIterator probe(FRegHead, FRegTail);

		while (*++probe != NULL)
		{
			FieldDesc *afield = (FieldDesc *)*probe;
			FieldTable.Push(*afield);
		}
		FieldTable.ShrinkToFit();
		qsort(&FieldTable[0], FieldTable.Size(), sizeof(FieldTable[0]), fieldcmp);
	}

}
コード例 #9
0
	//=============================================================================
	//
	//
	//
	//=============================================================================
	bool CreateSections()
	{
		int pick = 0;

		MarkInternalSubsectors();
		while (pick < numsubsectors)
		{
			if (ISDONE(pick, processed_subsectors)) 
			{
				pick++;
				continue;
			}


			subsector_t *subsector = &subsectors[pick];

			seg_t *workseg = NULL;
			vertex_t *startpt = NULL;

			NewSection(subsector->render_sector);
			while (1)
			{
				if (!ISDONE(subsector-subsectors, processed_subsectors))
				{
					SETDONE(subsector-subsectors, processed_subsectors);
					section->subsectors.Push(subsector);
					SectionForSubsector[subsector - subsectors] = int(section - &Sections[0]);
				}

				bool result = AddSubSector(subsector, startpt, &workseg);

				if (!result)
				{
					return false;	// couldn't create Sections
				}
				else if (workseg != NULL)
				{
					// crossing into another subsector
					seg_t *partner = workseg->PartnerSeg;
					if (workseg->v2 != partner->v1)
					{
						DPrintf("Inconsistent subsector references in seg %d. Cannot create Sections.\n", workseg-segs);
						return false;
					}
					subsector = partner->Subsector;
					startpt = workseg->v1;
				}
				else
				{
					// loop complete. Check adjoining subsectors for other loops to
					// be added to this section
					if (!FindNextSeg(&workseg))
					{
						return false;
					}
					else if (workseg == NULL)
					{
						// No more subsectors found. This section is complete!
						FinalizeSection();
						break;
					}
					else
					{
						subsector = workseg->Subsector;
						// If this is a regular seg, start there, otherwise start
						// at the subsector's first seg
						startpt = workseg->sidedef == NULL? NULL : workseg->v1;

						NewLoop();
					}
				}
			}
		}

		if (!CheckSections()) return false;
		SetReferences();

		Sections.ShrinkToFit();
		SectionLoops.ShrinkToFit();
		SectionLines.ShrinkToFit();

		tesselateSections();

		return true;
	}