123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- #include <stdlib.h>
- #include <stdio.h>
- #include "main.h"
- #include "Creature.h"
- #include "Game.h"
- #include "Character.h"
- creature CreateCreature(game g){
- creature G = NULL;
- G = malloc(sizeof(Creature));
- if(G) {
- G->Character = CreateCharacter(g);
- G->Next = NULL;
- return G;
- } else {
- fprintf( L, "Fatal error: failed to assign memory in CreateNode().\n" );
- exit(EXIT_FAILURE);
- }
- }
- void InsertCreatureNode( creature prev_obj, creature next_obj ){
- if( !next_obj ) {
- return;
- }
- if( !prev_obj ) {
- printf( "Prev object not found.\n" );
- CopyCreatureNode( prev_obj, next_obj );
- } else {
- next_obj->Next = prev_obj->Next;
- prev_obj->Next = next_obj;
- }
- }
- void CutCreatureNode( creature parent, creature child ){
- parent->Next = child->Next;
- child->Next = NULL;
- }
- void CopyCreatureNode( creature sink, creature source ){
- CopyCharacter( sink->Character, source->Character );
- sink->Next = source->Next;
- }
- void PurgeCreatureNode( creature N ){
- if(N) {
- PurgeCharacter(N->Character);
- DESTROY(N->Character);
- N->Next = NULL;
- }
- }
|