Skip to content

Commit 72b2c25

Browse files
committed
CPE_IsModelDefinedPtr implemented
1 parent 84814c6 commit 72b2c25

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

src/cpe.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ cs_bool CPE_IsModelDefined(cs_byte id) {
2929
return customModels[id] != NULL || id < 15;
3030
}
3131

32+
cs_bool CPE_IsModelDefinedPtr(CPEModel *model) {
33+
for(cs_int16 i = 0; i < 256; i++) {
34+
if(customModels[i] == model)
35+
return true;
36+
}
37+
return false;
38+
}
39+
3240
cs_str CPE_GetDefaultModelName(void) {
3341
return customModels[0] ? customModels[0]->name : originalModelNames[0];
3442
}
@@ -39,6 +47,7 @@ CPEModel *CPE_GetModel(cs_byte id) {
3947

4048
cs_bool CPE_DefineModel(cs_byte id, CPEModel *model) {
4149
if(!model->part || !model->partsCount) return false;
50+
if(CPE_IsModelDefinedPtr(model)) return false;
4251
customModels[id] = model;
4352
for(ClientID i = 0; i < MAX_CLIENTS; i++) {
4453
Client *client = Clients_List[i];

src/cpe.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "types/client.h"
66

77
API cs_bool CPE_IsModelDefined(cs_byte id);
8+
API cs_bool CPE_IsModelDefinedPtr(CPEModel *model);
89
API cs_str CPE_GetDefaultModelName(void);
910
API CPEModel *CPE_GetModel(cs_byte id);
1011
API cs_bool CPE_DefineModel(cs_byte id, CPEModel *model);

0 commit comments

Comments
 (0)