Skip to content
Permalink
Browse files

Make fd_flame_burst and fd_fire_vent display properly

  • Loading branch information...
fergus-dall committed Aug 20, 2013
1 parent f7eb335 commit 7d68ffd7d205af40b0c15f81e4c6c5a121ac894c
Showing with 20 additions and 6 deletions.
  1. +16 −6 field.cpp
  2. +4 −0 field.h
@@ -236,9 +236,6 @@ bool map::process_fields_in_submap(game *g, int gridn)
{
// Realistically this is always true, this function only gets called if fields exist.
bool found_field = false;
// Used to hold a copy of the current field.
// Do not addField or removeField with this variable (it's just a copy afterall).
field curfield;
// A pointer to the current field effect.
// Used to modify or otherwise get information on the field effect to update.
field_entry *cur;
@@ -256,7 +253,7 @@ bool map::process_fields_in_submap(game *g, int gridn)
int y = locy + SEEY * int(gridn / my_MAPSIZE);
// get a copy of the field variable from the submap;
// contains all the pointers to the real field effects.
curfield = grid[gridn]->fld[locx][locy];
field &curfield = grid[gridn]->fld[locx][locy];
for(std::map<field_id, field_entry *>::iterator it = curfield.getFieldStart();
it != curfield.getFieldEnd(); ++it ) {
//Iterating through all field effects in the submap's field.
@@ -691,7 +688,7 @@ bool map::process_fields_in_submap(game *g, int gridn)
cur->setFieldDensity(cur->getFieldDensity() - 1);
}
} else {
cur->setFieldType(fd_flame_burst);
curfield.replaceField(fd_fire_vent, fd_flame_burst);
cur->setFieldDensity(3);
}
break;
@@ -700,7 +697,7 @@ bool map::process_fields_in_submap(game *g, int gridn)
if (cur->getFieldDensity() > 1) {
cur->setFieldDensity(cur->getFieldDensity() - 1);
} else {
cur->setFieldType(fd_fire_vent);
curfield.replaceField(fd_flame_burst, fd_fire_vent);
cur->setFieldDensity(3);
}
break;
@@ -1599,6 +1596,19 @@ field_id field::fieldSymbol() const{
return draw_symbol;
}

bool field::replaceField(field_id old_field, field_id new_field)
{
field_entry* field = findField(old_field);
if (!field)
return false;
field->setFieldType(new_field);
field_list.erase(old_field);
field_list[new_field] = field;
if (draw_symbol == old_field)
draw_symbol = new_field;
return true;
}

int field::move_cost() const{
if(fieldCount() < 1){
return 0;
@@ -111,6 +111,8 @@ class field_entry {
int getFieldAge() const;

//Allows you to modify the field_id of the current field entry.
//This probably shouldn't be called outside of field::replaceField, as it
//breaks the field drawing code and field lookup
field_id setFieldType(const field_id new_field_id);

//Allows you to modify the density of the current field entry.
@@ -176,6 +178,8 @@ class field{
//This can be changed to return whatever you think the most important field to draw is.
field_id fieldSymbol() const;

bool replaceField(field_id old_field, field_id new_field);

//Returns the vector iterator to begin searching through the list.
//Note: If you are using "field_at" function, set the return to a temporary field variable! If you somehow
//query an out of bounds field location it returns a different field every inquery. This means that

0 comments on commit 7d68ffd

Please sign in to comment.
You can’t perform that action at this time.