| 10035 | -------------------------------------------------------------------------------*/ |
| 10036 | |
| 10037 | void getItemsOnTile(int x, int y, list_t** list) |
| 10038 | { |
| 10039 | |
| 10040 | //Take the return value of checkTileForEntity() and sort that list for items. |
| 10041 | //if( entity->behavior == &actItem ) |
| 10042 | //And then free the list returned by checkTileForEntity. |
| 10043 | |
| 10044 | //Right. First, grab all the entities on the tile. |
| 10045 | list_t* entities = NULL; |
| 10046 | entities = checkTileForEntity(x, y); |
| 10047 | |
| 10048 | if ( !entities ) |
| 10049 | { |
| 10050 | return; //No use continuing of got no entities. |
| 10051 | } |
| 10052 | |
| 10053 | node_t* node = NULL; |
| 10054 | node_t* node2 = NULL; |
| 10055 | //Loop through the list of entities. |
| 10056 | for ( node = entities->first; node != NULL; node = node->next ) |
| 10057 | { |
| 10058 | if ( node->element ) |
| 10059 | { |
| 10060 | Entity* entity = (Entity*)node->element; |
| 10061 | //Check if the entity is an item. |
| 10062 | if ( entity && entity->behavior == &actItem ) |
| 10063 | { |
| 10064 | //If this is the first item found, the list needs to be created. |
| 10065 | if ( !(*list) ) |
| 10066 | { |
| 10067 | *list = (list_t*)malloc(sizeof(list_t)); |
| 10068 | (*list)->first = NULL; |
| 10069 | (*list)->last = NULL; |
| 10070 | } |
| 10071 | |
| 10072 | //Add the current entity to it. |
| 10073 | node2 = list_AddNodeLast(*list); |
| 10074 | node2->element = entity; |
| 10075 | node2->deconstructor = &emptyDeconstructor; |
| 10076 | } |
| 10077 | } |
| 10078 | } |
| 10079 | |
| 10080 | /*if ( entities ) |
| 10081 | { |
| 10082 | list_FreeAll(entities); |
| 10083 | free(entities); |
| 10084 | }*/ |
| 10085 | |
| 10086 | //return return_val; |
| 10087 | } |
| 10088 | |
| 10089 | /*------------------------------------------------------------------------------- |
| 10090 |
no test coverage detected