Пример #1
0
void AmmoTerminate(AmmoClasses *ammo)
{
	AmmoClassesClear(&ammo->Ammo);
	CArrayTerminate(&ammo->Ammo);
	AmmoClassesClear(&ammo->CustomAmmo);
	CArrayTerminate(&ammo->CustomAmmo);
}
Пример #2
0
void WeaponTerminate(GunClasses *g)
{
	WeaponClassesClear(&g->Guns);
	CArrayTerminate(&g->Guns);
	WeaponClassesClear(&g->CustomGuns);
	CArrayTerminate(&g->CustomGuns);
}
Пример #3
0
void UIObjectDestroy(UIObject *o)
{
	size_t i;
	UIObject **objs = o->Children.data;
	CFREE(o->Tooltip);
	for (i = 0; i < o->Children.size; i++, objs++)
	{
		UIObjectDestroy(*objs);
	}
	CArrayTerminate(&o->Children);
	if (o->IsDynamicData)
	{
		CFREE(o->Data);
	}
	switch (o->Type)
	{
	case UITYPE_TEXTBOX:
		CFREE(o->u.Textbox.Hint);
		break;
	case UITYPE_TAB:
		CArrayTerminate(&o->u.Tab.Labels);
		break;
	default:
		// do nothing
		break;
	}
	CFREE(o);
}
Пример #4
0
void UIObjectDestroy(UIObject *o)
{
	CFREE(o->Tooltip);
	CA_FOREACH(UIObject *, obj, o->Children)
		UIObjectDestroy(*obj);
	CA_FOREACH_END()
	CArrayTerminate(&o->Children);
	if (o->IsDynamicData)
	{
		CFREE(o->Data);
	}
	switch (o->Type)
	{
	case UITYPE_TEXTBOX:
		CFREE(o->u.Textbox.Hint);
		break;
	case UITYPE_TAB:
		CArrayTerminate(&o->u.Tab.Labels);
		break;
	default:
		// do nothing
		break;
	}
	CFREE(o);
}
Пример #5
0
void SoundTerminate(SoundDevice *device, const bool waitForSoundsComplete)
{
	if (!device->isInitialised)
	{
		return;
	}

	debug(D_NORMAL, "shutting down sound\n");
	if (waitForSoundsComplete)
	{
		Uint32 waitStart = SDL_GetTicks();
		while (Mix_Playing(-1) > 0 &&
			SDL_GetTicks() - waitStart < 1000);
	}
	MusicStop(device);
	while (Mix_Init(0))
	{
		Mix_Quit();
	}
	Mix_CloseAudio();

	SoundClear(&device->sounds);
	CArrayTerminate(&device->sounds);
	SoundClear(&device->customSounds);
	CArrayTerminate(&device->customSounds);
}
Пример #6
0
void BulletTerminate(BulletClasses *bullets)
{
	BulletClassFree(&bullets->Default);
	BulletClassesClear(&bullets->Classes);
	CArrayTerminate(&bullets->Classes);
	BulletClassesClear(&bullets->CustomClasses);
	CArrayTerminate(&bullets->CustomClasses);
}
Пример #7
0
void MenuSystemTerminate(MenuSystem *ms)
{
	MenuDestroySubmenus(ms->root);
	CFREE(ms->root);
	CArrayTerminate(&ms->exitTypes);
	CArrayTerminate(&ms->customDisplayFuncs);
	memset(ms, 0, sizeof *ms);
}
Пример #8
0
void MapObjectsClear(CArray *classes)
{
	for (int i = 0; i < (int)classes->size; i++)
	{
		MapObject *c = CArrayGet(classes, i);
		CFREE(c->Name);
		CArrayTerminate(&c->DestroyGuns);
		CArrayTerminate(&c->DestroySpawn);
	}
	CArrayClear(classes);
}
Пример #9
0
void TileDestroy(Tile *t)
{
	if (t->triggers.elemSize > 0)
	{
		CArrayTerminate(&t->triggers);
	}
	if (t->things.elemSize > 0)
	{
		CArrayTerminate(&t->things);
	}
}
Пример #10
0
static void BulletClassFree(BulletClass *b)
{
	CFREE(b->Name);
	CFREE(b->HitSound.Object);
	CFREE(b->HitSound.Flesh);
	CFREE(b->HitSound.Wall);
	CArrayTerminate(&b->OutOfRangeGuns);
	CArrayTerminate(&b->HitGuns);
	CArrayTerminate(&b->Falling.DropGuns);
	CArrayTerminate(&b->ProximityGuns);
}
Пример #11
0
static void CampaignListTerminate(campaign_list_t *list)
{
	CFREE(list->Name);
	CA_FOREACH(campaign_list_t, sublist, list->subFolders)
		CampaignListTerminate(sublist);
	CA_FOREACH_END()
	CArrayTerminate(&list->subFolders);
	CA_FOREACH(CampaignEntry, e, list->list)
		CampaignEntryTerminate(e);
	CA_FOREACH_END()
	CArrayTerminate(&list->list);
}
Пример #12
0
void MapObjectsTerminate(MapObjects *classes)
{
	MapObjectsClear(&classes->Classes);
	CArrayTerminate(&classes->Classes);
	MapObjectsClear(&classes->CustomClasses);
	CArrayTerminate(&classes->CustomClasses);
	CA_FOREACH(char *, s, classes->Destructibles)
		CFREE(*s);
	CA_FOREACH_END()
	CArrayTerminate(&classes->Destructibles);
	CA_FOREACH(char *, s, classes->Bloods)
		CFREE(*s);
	CA_FOREACH_END()
	CArrayTerminate(&classes->Bloods);
}
Пример #13
0
void MissionStaticLayout(Mission *m, Vec2i oldSize)
{
	assert(m->Type == MAPTYPE_STATIC && "invalid map type");
	// re-layout the static map after a resize
	// The mission contains the new size; the old dimensions are oldSize
	// Simply try to "paint" the old tiles to the new mission
	Vec2i v;
	CArray oldTiles;
	CArrayInit(&oldTiles, m->u.Static.Tiles.elemSize);
	CArrayCopy(&oldTiles, &m->u.Static.Tiles);

	// Clear the tiles first
	CArrayTerminate(&m->u.Static.Tiles);
	CArrayInit(&m->u.Static.Tiles, oldTiles.elemSize);
	for (v.y = 0; v.y < m->Size.y; v.y++)
	{
		for (v.x = 0; v.x < m->Size.x; v.x++)
		{
			unsigned short tile = MAP_FLOOR;
			CArrayPushBack(&m->u.Static.Tiles, &tile);
		}
	}

	// Paint the old tiles back
	for (v.y = 0; v.y < m->Size.y; v.y++)
	{
		for (v.x = 0; v.x < m->Size.x; v.x++)
		{
			if (v.x >= oldSize.x || v.y >= oldSize.y)
			{
				MissionTrySetTile(m, v, MAP_NOTHING);
			}
			else
			{
				int idx = v.y * oldSize.x + v.x;
				unsigned short *tile = CArrayGet(&oldTiles, idx);
				MissionTrySetTile(m, v, *tile);
			}
		}
	}

	CArrayTerminate(&oldTiles);

	if (m->u.Static.Start.x >= m->Size.x || m->u.Static.Start.y >= m->Size.y)
	{
		m->u.Static.Start = Vec2iZero();
	}
}
Пример #14
0
void AutosaveTerminate(Autosave *autosave)
{
	CA_FOREACH(MissionSave, m, autosave->Missions)
		CampaignEntryTerminate(&m->Campaign);
	CA_FOREACH_END()
	CArrayTerminate(&autosave->Missions);
}
Пример #15
0
void JoyTerminate(CArray *joys)
{
	CA_FOREACH(Joystick, j, *joys)
		JoyTerminateOne(j);
	CA_FOREACH_END()
	CArrayTerminate(joys);
}
Пример #16
0
static void PlayerListTerminate(GameLoopData *data)
{
	PlayerList *pl = data->Data;

	CArrayTerminate(&pl->playerUIDs);
	MenuSystemTerminate(&pl->ms);
	CFREE(pl->data);
	CFREE(pl);
}
Пример #17
0
void MapObjectsTerminate(MapObjects *classes)
{
	MapObjectsClear(&classes->Classes);
	CArrayTerminate(&classes->Classes);
	MapObjectsClear(&classes->CustomClasses);
	CArrayTerminate(&classes->CustomClasses);
	for (int i = 0; i < (int)classes->Destructibles.size; i++)
	{
		char **s = CArrayGet(&classes->Destructibles, i);
		CFREE(*s);
	}
	CArrayTerminate(&classes->Destructibles);
	for (int i = 0; i < (int)classes->Bloods.size; i++)
	{
		char **s = CArrayGet(&classes->Bloods, i);
		CFREE(*s);
	}
	CArrayTerminate(&classes->Bloods);
}
Пример #18
0
void RemoveAllWatches(void)
{
	TWatch *t;

	while (activeWatches) {
		t = activeWatches;
		activeWatches = t->next;
		CArrayTerminate(&t->conditions);
		CArrayTerminate(&t->actions);
		CFREE(t);
	}
	while (inactiveWatches) {
		t = inactiveWatches;
		inactiveWatches = t->next;
		CArrayTerminate(&t->conditions);
		CArrayTerminate(&t->actions);
		CFREE(t);
	}
}
Пример #19
0
void ConfigDestroy(Config *c)
{
	CFREE(c->Name);
	if (c->Type == CONFIG_TYPE_GROUP)
	{
		CA_FOREACH(Config, child, c->u.Group)
			ConfigDestroy(child);
		CA_FOREACH_END()
		CArrayTerminate(&c->u.Group);
	}
}
Пример #20
0
void MobObjsTerminate(void)
{
	for (int i = 0; i < (int)gMobObjs.size; i++)
	{
		TMobileObject *m = CArrayGet(&gMobObjs, i);
		if (m->isInUse)
		{
			MobObjDestroy(i);
		}
	}
	CArrayTerminate(&gMobObjs);
}
Пример #21
0
void ObjsTerminate(void)
{
	for (int i = 0; i < (int)gObjs.size; i++)
	{
		TObject *o = CArrayGet(&gObjs, i);
		if (o->isInUse)
		{
			ObjDestroy(i);
		}
	}
	CArrayTerminate(&gObjs);
}
Пример #22
0
void PicManagerTerminate(PicManager *pm)
{
	for (int i = 0; i < PIC_MAX; i++)
	{
		if (pm->oldPics[i] != NULL)
		{
			CFREE(pm->oldPics[i]);
		}
		if (PicIsNotNone(&pm->picsFromOld[i]))
		{
			PicFree(&pm->picsFromOld[i]);
		}
	}
	PicManagerClear(&pm->pics, &pm->sprites);
	CArrayTerminate(&pm->pics);
	CArrayTerminate(&pm->sprites);
	PicManagerClear(&pm->customPics, &pm->customSprites);
	CArrayTerminate(&pm->customPics);
	CArrayTerminate(&pm->customSprites);
	IMG_Quit();
}
Пример #23
0
void PickupsTerminate(void)
{
	for (int i = 0; i < (int)gPickups.size; i++)
	{
		const Pickup *p = CArrayGet(&gPickups, i);
		if (p->isInUse)
		{
			PickupDestroy(i);
		}
	}
	CArrayTerminate(&gPickups);
}
Пример #24
0
void CampaignSettingTerminate(CampaignSetting *setting)
{
	CFREE(setting->Title);
	CFREE(setting->Author);
	CFREE(setting->Description);
	CA_FOREACH(Mission, m, setting->Missions)
		MissionTerminate(m);
	CA_FOREACH_END()
	CArrayTerminate(&setting->Missions);
	CharacterStoreTerminate(&setting->characters);
	memset(setting, 0, sizeof *setting);
}
Пример #25
0
void NamedSpritesFree(NamedSprites *ns)
{
	if (ns == NULL)
	{
		return;
	}
	CFREE(ns->name);
	for (int i = 0; i < (int)ns->pics.size; i++)
	{
		PicFree(CArrayGet(&ns->pics, i));
	}
	CArrayTerminate(&ns->pics);
}
Пример #26
0
void NetInputTerminate(NetInput *n)
{
    enet_host_destroy(n->server);
    n->server = NULL;
    for (int i = 0; i < (int)n->peers.size; i++)
    {
        ENetPeer **p = CArrayGet(&n->peers, i);
        if (*p)
        {
            enet_peer_reset(*p);
        }
    }
    CArrayTerminate(&n->peers);
}
Пример #27
0
void GraphicsTerminate(GraphicsDevice *g)
{
    debug(D_NORMAL, "Shutting down video...\n");
    CArrayTerminate(&g->validModes);
    SDL_FreeSurface(g->icon);
    SDL_DestroyTexture(g->screen);
    SDL_DestroyTexture(g->bkg);
    SDL_DestroyTexture(g->brightnessOverlay);
    SDL_DestroyRenderer(g->renderer);
    SDL_FreeFormat(g->Format);
    SDL_DestroyWindow(g->window);
    SDL_VideoQuit();
    CFREE(g->buf);
}
static void CreateAddCharacterSubObjs(UIObject *c, void *vData)
{
	EditorBrushAndCampaign *data = vData;
	CharacterStore *store = &data->Campaign->Setting.characters;
	if (c->Children.size == store->OtherChars.size)
	{
		return;
	}
	// Recreate the child UI objects
	c->Highlighted = NULL;
	UIObject **objs = c->Children.data;
	for (int i = 0; i < (int)c->Children.size; i++, objs++)
	{
		UIObjectDestroy(*objs);
	}
	CArrayTerminate(&c->Children);
	CArrayInit(&c->Children, sizeof c);

	UIObject *o = UIObjectCreate(
		UITYPE_CUSTOM, 0,
		Vec2iZero(), Vec2iNew(TILE_WIDTH + 4, TILE_HEIGHT * 2 + 4));
	o->ChangeFunc = BrushSetBrushTypeAddCharacter;
	o->u.CustomDrawFunc = DrawCharacter;
	o->OnFocusFunc = ActivateEditorBrushAndCampaignBrush;
	o->OnUnfocusFunc = DeactivateEditorBrushAndCampaignBrush;
	Vec2i pos = Vec2iZero();
	int width = 8;
	for (int i = 0; i < (int)store->OtherChars.size; i++)
	{
		UIObject *o2 = UIObjectCopy(o);
		Character *ch = CArrayGet(&store->OtherChars, i);
		CSTRDUP(o2->Tooltip, ch->Gun->name);
		o2->IsDynamicData = 1;
		CMALLOC(o2->Data, sizeof(EditorBrushAndCampaign));
		((EditorBrushAndCampaign *)o2->Data)->Brush.Brush = data->Brush.Brush;
		((EditorBrushAndCampaign *)o2->Data)->Campaign = data->Campaign;
		((EditorBrushAndCampaign *)o2->Data)->Brush.u.ItemIndex = i;
		o2->Pos = pos;
		UIObjectAddChild(c, o2);
		pos.x += o->Size.x;
		if (((i + 1) % width) == 0)
		{
			pos.x = 0;
			pos.y += o->Size.y;
		}
	}
	UIObjectDestroy(o);
}
Пример #29
0
void MenuDestroySubmenus(menu_t *menu)
{
	if (menu == NULL)
	{
		return;
	}
	CFREE(menu->name);
	if (MenuTypeHasSubMenus(menu->type))
	{
		for (int i = 0; i < (int)menu->u.normal.subMenus.size; i++)
		{
			menu_t *subMenu = CArrayGet(&menu->u.normal.subMenus, i);
			MenuDestroySubmenus(subMenu);
		}
		CArrayTerminate(&menu->u.normal.subMenus);
	}
}
Пример #30
0
void MissionOptionsTerminate(struct MissionOptions *mo)
{
	ActorsTerminate();
	ObjsTerminate();
	MobObjsTerminate();
	PickupsTerminate();
	ParticlesTerminate(&gParticles);
	WatchesTerminate();
	CA_FOREACH(PlayerData, p, gPlayerDatas)
		p->ActorUID = -1;
	CA_FOREACH_END()
	gMission.HasStarted = false;
	gMission.HasBegun = false;
	CArrayTerminate(&mo->Weapons);

	memset(mo, 0, sizeof *mo);
}