mirror of
https://github.com/CPunch/Cosmo.git
synced 2025-11-17 04:30:05 +00:00
Added OP_POW to cdebug.c; refactored cosmoV_registerProtoObject
- cosmoV_registerProtoObject now walks the object list and updates the proto's for objects of the objType which have a NULL proto. - misc. comment changes in cvm.h as well.
This commit is contained in:
11
src/cvm.c
11
src/cvm.c
@@ -427,6 +427,17 @@ COSMO_API CObjObject* cosmoV_makeObject(CState *state, int pairs) {
|
||||
COSMO_API bool cosmoV_registerProtoObject(CState *state, CObjType objType, CObjObject *obj) {
|
||||
bool replaced = state->protoObjects[objType] != NULL;
|
||||
state->protoObjects[objType] = obj;
|
||||
|
||||
// walk through the object list
|
||||
CObj *curr = state->objects;
|
||||
while (curr != NULL) {
|
||||
// update the proto
|
||||
if (curr->type == objType && curr->proto != NULL) {
|
||||
curr->proto = obj;
|
||||
}
|
||||
curr = curr->next;
|
||||
}
|
||||
|
||||
return replaced;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user