This is my current code which works if the loop isn;t that long (max 10k)
std::vector<int> mobList()
{
std::vector<int> list;
PyObject* mod = PyObject_GetAttrString(PyImport_AddModule("player"), "GetCharacterDistance");
PyObject* mod2 = PyObject_GetAttrString(PyImport_AddModule("chr"), "GetInstanceType");
PyObject* args = PyTuple_New(1);
std::vector<int> mobs;
for (int i = 0; i < 100000; i++) {
PyTuple_SetItem(args, 0, PyInt_FromLong(i));
PyObject* mob = PyObject_CallObject(mod, args);
if (!mob) {
Py_DECREF(mob);
Py_XDECREF(args);
}
else {
PyObject* enemy = PyObject_CallObject(mod2, args);
if (!enemy) {
Py_DECREF(enemy);
Py_XDECREF(args);
}
else {
if (PyInt_AsLong(mob) > 0 && PyInt_AsLong(mob) < 1000 && PyInt_AsLong(enemy) == 0) {
mobs.push_back(i);
}
}
}
}
return mobs;
}
100k still crashes it ? I've found out that 0xC0000409 causes it. My client simply closes and I do not receive any logs except CrashDumps.