You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
88 lines
2.1 KiB
88 lines
2.1 KiB
#include "building.h"
|
|
#include <stdlib.h>
|
|
#include "../game.h"
|
|
|
|
Building * BuildingInit(Game *game, int id, int x, int y){
|
|
Sprite *newSprite = SpriteCreate(game->textures, TE_BAUSTELLE, x, y);
|
|
SpriteListInsert(game->sprites, newSprite);
|
|
|
|
Building *new = malloc(sizeof(Building));
|
|
|
|
new->sprite = newSprite;
|
|
new->id = id;
|
|
new->isBaustelle = 1;
|
|
new->progress = 0;
|
|
|
|
new->next = 0;
|
|
new->prev = 0;
|
|
|
|
return new;
|
|
}
|
|
|
|
BuildingList * BuildingListInit(){
|
|
BuildingList *new = malloc(sizeof(BuildingList));
|
|
new->head = 0;
|
|
new->tail = 0;
|
|
return new;
|
|
}
|
|
|
|
void BuildingFinishConstruction(Game *game, Building *building){
|
|
building->isBaustelle = 0;
|
|
|
|
int textureId = 0;
|
|
|
|
switch(building->id){
|
|
case BU_HOUSE:
|
|
textureId = TE_BUILDING;
|
|
break;
|
|
default:
|
|
printf("WARNING: BUILDINGFINDISHEDCONSTRADJFALKDF AUFGERUFEN MIT UNBEKANNTER ID111!!\n");
|
|
}
|
|
|
|
building->sprite->texture = game->textures->textures[textureId];
|
|
|
|
// Zur Sicherheit. Sollte eigentlich nix ändern, weil texture hmmpf früher bescheid wisse
|
|
SpriteListSpriteChanged(game->sprites, building->sprite);
|
|
}
|
|
|
|
void BuildingListPrintForward(BuildingList *buildings){
|
|
|
|
}
|
|
|
|
void BuildingListInsert(BuildingList *buildings, Building *data){
|
|
if(buildings->head == 0){
|
|
buildings->head = data;
|
|
buildings->tail = data;
|
|
}
|
|
else{
|
|
buildings->tail->next = data;
|
|
data->prev = buildings->tail;
|
|
buildings->tail = data;
|
|
}
|
|
}
|
|
|
|
void BuildingListRemove(BuildingList *buildings, Building *remove){
|
|
if(remove == 0){
|
|
printf("WARNING: TRIED TO REMOVE NULLPOINTER\n");
|
|
}
|
|
else if(buildings->head == remove && buildings->tail == remove){
|
|
buildings->head = 0;
|
|
buildings->tail = 0;
|
|
}
|
|
else if(buildings->head == remove){
|
|
remove->next->prev = 0;
|
|
buildings->head = remove->next;
|
|
}
|
|
else if(buildings->tail == remove){
|
|
remove->prev->next = 0;
|
|
buildings->tail = remove->prev;
|
|
}
|
|
else{
|
|
remove->prev->next = remove->next;
|
|
remove->next->prev = remove->prev;
|
|
}
|
|
|
|
remove->next = 0;
|
|
remove->prev = 0;
|
|
}
|