parent
efa37825db
commit
be7665d5c5
@ -1,8 +1,22 @@
|
||||
#include <stdlib.h>
|
||||
#include "task.h"
|
||||
#include "../definitions.h"
|
||||
|
||||
Task * TaskInit(){
|
||||
Task * TaskInit(int workerid){
|
||||
Task *new = malloc(sizeof(Task));
|
||||
new->target = 0;
|
||||
new->progress = 0;
|
||||
int repeat = 0;
|
||||
|
||||
switch(workerid){
|
||||
case PR_BUILDER:
|
||||
repeat = 0;
|
||||
break;
|
||||
default:
|
||||
repeat = 0;
|
||||
}
|
||||
|
||||
new->repeat = repeat;
|
||||
|
||||
return new;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
#ifndef TASK_H_
|
||||
#define TASK_H_
|
||||
|
||||
typedef struct Task Task;
|
||||
|
||||
typedef struct Task{
|
||||
void *target;
|
||||
float progress;
|
||||
int repeat;
|
||||
} Task;
|
||||
|
||||
Task * TaskInit();
|
||||
Task * TaskInit(int workerid);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -0,0 +1,86 @@
|
||||
#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->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;
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
#ifndef BUILDING_H_
|
||||
#define BUILDING_H_
|
||||
#include "../Sprite/sprite.h"
|
||||
#include "../game.h"
|
||||
|
||||
typedef struct Building{
|
||||
Sprite *sprite;
|
||||
int id;
|
||||
int isBaustelle;
|
||||
|
||||
struct Building *next;
|
||||
struct Building *prev;
|
||||
} Building;
|
||||
|
||||
typedef struct BuildingList {
|
||||
Building *head;
|
||||
Building *tail;
|
||||
} BuildingList;
|
||||
|
||||
Building * BuildingInit(Game *game, int id, int x, int y);
|
||||
BuildingList * BuildingListInit();
|
||||
|
||||
void BuildingFinishConstruction(Game *game, Building *building);
|
||||
void BuildingListPrintForward(BuildingList *buildings);
|
||||
void BuildingListInsert(BuildingList *buildings, Building *data);
|
||||
void BuildingListRemove(BuildingList *buildings, Building *remove);
|
||||
|
||||
#endif
|
||||
@ -1,60 +0,0 @@
|
||||
#include "mapobject.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
MapObject * MapObjectInit(Sprite *sprite, int id){
|
||||
MapObject *new = malloc(sizeof(MapObject));
|
||||
|
||||
new->sprite = sprite;
|
||||
new->id = id;
|
||||
new->next = 0;
|
||||
new->prev = 0;
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
MapObjectList * MapObjectListInit(){
|
||||
MapObjectList *new = malloc(sizeof(MapObjectList));
|
||||
new->head = 0;
|
||||
new->tail = 0;
|
||||
return new;
|
||||
}
|
||||
|
||||
void MapObjectListPrintForward(MapObjectList *mapObjects){
|
||||
|
||||
}
|
||||
|
||||
void MapObjectListInsert(MapObjectList *mapObjects, MapObject *data){
|
||||
if(mapObjects->head == 0){
|
||||
mapObjects->head = data;
|
||||
mapObjects->tail = data;
|
||||
}
|
||||
else{
|
||||
mapObjects->tail->next = data;
|
||||
data->prev = mapObjects->tail;
|
||||
mapObjects->tail = data;
|
||||
}
|
||||
}
|
||||
void MapObjectListRemove(MapObjectList *mapObjects, MapObject *remove){
|
||||
if(remove == 0){
|
||||
printf("WARNING: TRIED TO REMOVE NULLPOINTER\n");
|
||||
}
|
||||
else if(mapObjects->head == remove && mapObjects->tail == remove){
|
||||
mapObjects->head = 0;
|
||||
mapObjects->tail = 0;
|
||||
}
|
||||
else if(mapObjects->head == remove){
|
||||
remove->next->prev = 0;
|
||||
mapObjects->head = remove->next;
|
||||
}
|
||||
else if(mapObjects->tail == remove){
|
||||
remove->prev->next = 0;
|
||||
mapObjects->tail = remove->prev;
|
||||
}
|
||||
else{
|
||||
remove->prev->next = remove->next;
|
||||
remove->next->prev = remove->prev;
|
||||
}
|
||||
|
||||
remove->next = 0;
|
||||
remove->prev = 0;
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
#ifndef MAPOBJECT_H_
|
||||
#define MAPOBJECT_H_
|
||||
#include "../Sprite/sprite.h"
|
||||
|
||||
typedef struct MapObject MapObject;
|
||||
typedef struct MapObjectList MapObjectList;
|
||||
|
||||
typedef struct MapObject{
|
||||
Sprite *sprite;
|
||||
int id;
|
||||
|
||||
MapObject *next;
|
||||
MapObject *prev;
|
||||
} MapObject;
|
||||
|
||||
typedef struct MapObjectList{
|
||||
MapObject *head;
|
||||
MapObject *tail;
|
||||
} MapObjectList;
|
||||
|
||||
MapObject * MapObjectInit(Sprite *sprite, int id);
|
||||
MapObjectList * MapObjectListInit();
|
||||
|
||||
void MapObjectListPrintForward(MapObjectList *mapObjects);
|
||||
void MapObjectListInsert(MapObjectList *mapObjects, MapObject *data);
|
||||
void MapObjectListRemove(MapObjectList *mapObjects, MapObject *remove);
|
||||
|
||||
#endif
|
||||
Loading…
Reference in new issue