1.1 --- a/core/smn_entities.cpp Mon Aug 27 19:31:38 2012 -0400
1.2 +++ b/core/smn_entities.cpp Tue Aug 28 16:20:15 2012 -0400
1.3 @@ -325,7 +325,7 @@
1.4 return pContext->ThrowNativeError("Invalid edict (%d - %d)", g_HL2.ReferenceToIndex(params[1]), params[1]);
1.5 }
1.6
1.7 - const char *cls = pEdict->GetClassName();
1.8 + const char *cls = g_HL2.GetEntityClassname(pEdict);
1.9
1.10 if (!cls || cls[0] == '\0')
1.11 {
1.12 @@ -961,10 +961,11 @@
1.13 } \
1.14 if ((td = g_HL2.FindInDataMap(pMap, prop)) == NULL) \
1.15 { \
1.16 + const char *class_name = g_HL2.GetEntityClassname(pEntity); \
1.17 return pContext->ThrowNativeError("Property \"%s\" not found (entity %d/%s)", \
1.18 prop, \
1.19 params[1], \
1.20 - class_name); \
1.21 + ((class_name) ? class_name : "")); \
1.22 }
1.23
1.24 #define CHECK_SET_PROP_DATA_OFFSET() \
1.25 @@ -988,10 +989,11 @@
1.26 } \
1.27 if (!g_HL2.FindSendPropInfo(pNet->GetServerClass()->GetName(), prop, &info)) \
1.28 { \
1.29 + const char *class_name = g_HL2.GetEntityClassname(pEntity); \
1.30 return pContext->ThrowNativeError("Property \"%s\" not found (entity %d/%s)", \
1.31 prop, \
1.32 params[1], \
1.33 - class_name); \
1.34 + ((class_name) ? class_name : "")); \
1.35 } \
1.36 \
1.37 offset = info.actual_offset; \
1.38 @@ -1082,7 +1084,6 @@
1.39 {
1.40 CBaseEntity *pEntity;
1.41 char *prop;
1.42 - const char *class_name;
1.43 edict_t *pEdict;
1.44
1.45 if (!IndexToAThings(params[1], &pEntity, &pEdict))
1.46 @@ -1090,11 +1091,6 @@
1.47 return pContext->ThrowNativeError("Entity %d (%d) is invalid", g_HL2.ReferenceToIndex(params[1]), params[1]);
1.48 }
1.49
1.50 - if (!pEdict || (class_name = pEdict->GetClassName()) == NULL)
1.51 - {
1.52 - class_name = "";
1.53 - }
1.54 -
1.55 pContext->LocalToString(params[3], &prop);
1.56
1.57 switch (params[2])
1.58 @@ -1119,10 +1115,11 @@
1.59 }
1.60 if (!g_HL2.FindSendPropInfo(pNet->GetServerClass()->GetName(), prop, &info))
1.61 {
1.62 + const char *class_name = g_HL2.GetEntityClassname(pEntity);
1.63 return pContext->ThrowNativeError("Property \"%s\" not found (entity %d/%s)",
1.64 prop,
1.65 params[1],
1.66 - class_name);
1.67 + ((class_name) ? class_name : ""));
1.68 }
1.69
1.70 if (info.prop->GetType() != DPT_DataTable)
1.71 @@ -1152,7 +1149,6 @@
1.72 CBaseEntity *pEntity;
1.73 char *prop;
1.74 int offset;
1.75 - const char *class_name;
1.76 edict_t *pEdict;
1.77 int bit_count;
1.78 bool is_unsigned = false;
1.79 @@ -1168,12 +1164,6 @@
1.80 return pContext->ThrowNativeError("Entity %d (%d) is invalid", g_HL2.ReferenceToIndex(params[1]), params[1]);
1.81 }
1.82
1.83 - /* TODO: Find a way to lookup classname without having an edict - Is this a guaranteed prop? */
1.84 - if (!pEdict || (class_name = pEdict->GetClassName()) == NULL)
1.85 - {
1.86 - class_name = "";
1.87 - }
1.88 -
1.89 pContext->LocalToString(params[3], &prop);
1.90
1.91 switch (params[2])
1.92 @@ -1251,7 +1241,6 @@
1.93 CBaseEntity *pEntity;
1.94 char *prop;
1.95 int offset;
1.96 - const char *class_name;
1.97 edict_t *pEdict;
1.98 int bit_count;
1.99
1.100 @@ -1266,11 +1255,6 @@
1.101 return pContext->ThrowNativeError("Entity %d (%d) is invalid", g_HL2.ReferenceToIndex(params[1]), params[1]);
1.102 }
1.103
1.104 - if (!pEdict || (class_name = pEdict->GetClassName()) == NULL)
1.105 - {
1.106 - class_name = "";
1.107 - }
1.108 -
1.109 pContext->LocalToString(params[3], &prop);
1.110
1.111 switch (params[2])
1.112 @@ -1339,7 +1323,6 @@
1.113 char *prop;
1.114 int offset;
1.115 int bit_count;
1.116 - const char *class_name;
1.117 edict_t *pEdict;
1.118
1.119 int element = 0;
1.120 @@ -1353,11 +1336,6 @@
1.121 return pContext->ThrowNativeError("Entity %d (%d) is invalid", g_HL2.ReferenceToIndex(params[1]), params[1]);
1.122 }
1.123
1.124 - if (!pEdict || (class_name = pEdict->GetClassName()) == NULL)
1.125 - {
1.126 - class_name = "";
1.127 - }
1.128 -
1.129 pContext->LocalToString(params[3], &prop);
1.130
1.131 switch (params[2])
1.132 @@ -1404,7 +1382,6 @@
1.133 char *prop;
1.134 int offset;
1.135 int bit_count;
1.136 - const char *class_name;
1.137 edict_t *pEdict;
1.138
1.139 int element = 0;
1.140 @@ -1418,11 +1395,6 @@
1.141 return pContext->ThrowNativeError("Entity %d (%d) is invalid", g_HL2.ReferenceToIndex(params[1]), params[1]);
1.142 }
1.143
1.144 - if (!pEdict || (class_name = pEdict->GetClassName()) == NULL)
1.145 - {
1.146 - class_name = "";
1.147 - }
1.148 -
1.149 pContext->LocalToString(params[3], &prop);
1.150
1.151 switch (params[2])
1.152 @@ -1474,7 +1446,6 @@
1.153 char *prop;
1.154 int offset;
1.155 int bit_count;
1.156 - const char *class_name;
1.157 edict_t *pEdict;
1.158
1.159 int element = 0;
1.160 @@ -1488,11 +1459,6 @@
1.161 return pContext->ThrowNativeError("Entity %d (%d) is invalid", g_HL2.ReferenceToIndex(params[1]), params[1]);
1.162 }
1.163
1.164 - if (!pEdict || (class_name = pEdict->GetClassName()) == NULL)
1.165 - {
1.166 - class_name = "";
1.167 - }
1.168 -
1.169 pContext->LocalToString(params[3], &prop);
1.170
1.171 switch (params[2])
1.172 @@ -1538,7 +1504,6 @@
1.173 char *prop;
1.174 int offset;
1.175 int bit_count;
1.176 - const char *class_name;
1.177 edict_t *pEdict;
1.178
1.179 int element = 0;
1.180 @@ -1552,11 +1517,6 @@
1.181 return pContext->ThrowNativeError("Entity %d (%d) is invalid", g_HL2.ReferenceToIndex(params[1]), params[1]);
1.182 }
1.183
1.184 - if (!pEdict || (class_name = pEdict->GetClassName()) == NULL)
1.185 - {
1.186 - class_name = "";
1.187 - }
1.188 -
1.189 pContext->LocalToString(params[3], &prop);
1.190
1.191 switch (params[2])
1.192 @@ -1623,7 +1583,6 @@
1.193 char *prop;
1.194 int offset;
1.195 int bit_count;
1.196 - const char *class_name;
1.197 edict_t *pEdict;
1.198
1.199 int element = 0;
1.200 @@ -1637,11 +1596,6 @@
1.201 return pContext->ThrowNativeError("Entity %d (%d) is invalid", g_HL2.ReferenceToIndex(params[1]), params[1]);
1.202 }
1.203
1.204 - if (!pEdict || (class_name = pEdict->GetClassName()) == NULL)
1.205 - {
1.206 - class_name = "";
1.207 - }
1.208 -
1.209 pContext->LocalToString(params[3], &prop);
1.210
1.211 switch (params[2])
1.212 @@ -1695,7 +1649,6 @@
1.213 char *prop;
1.214 int offset;
1.215 int bit_count;
1.216 - const char *class_name;
1.217 edict_t *pEdict;
1.218
1.219 int element = 0;
1.220 @@ -1709,11 +1662,6 @@
1.221 return pContext->ThrowNativeError("Entity %d (%d) is invalid", g_HL2.ReferenceToIndex(params[1]), params[1]);
1.222 }
1.223
1.224 - if (!pEdict || (class_name = pEdict->GetClassName()) == NULL)
1.225 - {
1.226 - class_name = "";
1.227 - }
1.228 -
1.229 pContext->LocalToString(params[3], &prop);
1.230
1.231 switch (params[2])
1.232 @@ -1771,7 +1719,6 @@
1.233 CBaseEntity *pEntity;
1.234 char *prop;
1.235 int offset;
1.236 - const char *class_name;
1.237 edict_t *pEdict;
1.238 bool bIsStringIndex;
1.239
1.240 @@ -1786,11 +1733,6 @@
1.241 return pContext->ThrowNativeError("Entity %d (%d) is invalid", g_HL2.ReferenceToIndex(params[1]), params[1]);
1.242 }
1.243
1.244 - if (!pEdict || (class_name = pEdict->GetClassName()) == NULL)
1.245 - {
1.246 - class_name = "";
1.247 - }
1.248 -
1.249 pContext->LocalToString(params[3], &prop);
1.250
1.251 bIsStringIndex = false;
1.252 @@ -1849,10 +1791,11 @@
1.253 }
1.254 if (!g_HL2.FindSendPropInfo(pNet->GetServerClass()->GetName(), prop, &info))
1.255 {
1.256 + const char *class_name = g_HL2.GetEntityClassname(pEntity);
1.257 return pContext->ThrowNativeError("Property \"%s\" not found (entity %d/%s)",
1.258 prop,
1.259 params[1],
1.260 - class_name);
1.261 + ((class_name) ? class_name : ""));
1.262 }
1.263
1.264 offset = info.actual_offset;