Skip to content

Commit

Permalink
Add CreateAllowed and ChangeType events
Browse files Browse the repository at this point in the history
Used in create_part, kill_part, and part_change_type, allows us to remove element-specific stuff in those functions
Note: difference between Create and ChangeType is that Create is called when we want to initialize default element properties, but ChangeType is called every time a particle is changed to that type, even if it doesn't need default properties set. ChangeType is mainly used for things that need accurate state tracking, like the stkm spawn status.
ChangeType is called every time a particle is changed to or from its type, which includes if the particle is deleted, and also Lua.

Neither of these functions are called when loading saves, that's probably an oversight, will fix later
  • Loading branch information
jacob1 committed Nov 30, 2019
1 parent 9993290 commit bf7d182
Show file tree
Hide file tree
Showing 11 changed files with 275 additions and 219 deletions.
2 changes: 0 additions & 2 deletions src/client/GameSave.cpp
Expand Up @@ -755,8 +755,6 @@ void GameSave::readOPS(char * data, int dataLength)
stkm.fanFigh.push_back(bson_iterator_int(&fighiter));
}
}
else
fprintf(stderr, "Unknown stkm property %s\n", bson_iterator_key(&stkmiter));
}
}
else
Expand Down
4 changes: 4 additions & 0 deletions src/simulation/ElementDefs.h
Expand Up @@ -47,6 +47,10 @@

#define ELEMENT_CREATE_FUNC_ARGS Simulation *sim, int i, int x, int y, int t, int v

#define ELEMENT_CREATE_ALLOWED_FUNC_ARGS Simulation *sim, int i, int x, int y, int t

#define ELEMENT_CHANGETYPE_FUNC_ARGS Simulation *sim, int i, int x, int y, int from, int to

#define CTYPEDRAW_FUNC_ARGS Simulation *sim, int i, int t, int v
#define CTYPEDRAW_FUNC_SUBCALL_ARGS sim, i, t, v

Expand Down

0 comments on commit bf7d182

Please sign in to comment.