severs64 Posted June 15, 2014 Share Posted June 15, 2014 OK, so I'm writing an OBSE plugin to send values (Attributes, Skills, etc) to an Android app. Not using an actual script, just the dll. It's working really well, except I'm having a bit of a struggle with the gold. I'm using the following code in the load game: ExtraContainerChanges* exCont = NULL;ExtraContainerChanges::EntryData *entry = NULL;TESForm *gold;void MessageHandler(OBSEMessagingInterface::Message* msg){ switch (msg->type) { case OBSEMessagingInterface::kMessage_LoadGame: player = *g_thePlayer; if (player != NULL) { basedata = (TESActorBaseData *)Oblivion_DynamicCast(player->baseForm, 0, RTTI_TESForm, RTTI_TESActorBaseData, 0); player_class = player->GetPlayerClass(); player_name = player->GetFullName(); exCont = static_cast <ExtraContainerChanges *>(player->baseExtraList.GetByType(kExtraData_ContainerChanges)); OR exCont = ExtraContainerChanges::GetForRef(player); gold = GetGoldForm(); } Then in my GetValues function: if (exCont) { entry = exCont->GetByType(gold); if (entry) values->gold = entry->countDelta; } TESForm *GetGoldForm(){ int i = 0; TESForm *frm = player->GetInventoryItem(i++, false); while (frm) { if (frm->refID == 15) return frm; frm = player->GetInventoryItem(i++, false); }; return NULL;} This works fine, except that sometimes when loading a different save ingame, I get a crash. The data variable in exCont gets trashed somehow, and I get an access violation. So, a couple of questions:1. Is this the best way to find the players gold amount? Again, not using a script.2. Am I using the ExtraContainerChanges wrongly? If so, what's the right way? Thanks for any help... Here's a pic of my Xoom running the app in case anyone is curious... Link to comment Share on other sites More sharing options...
QQuix Posted June 19, 2014 Share Posted June 19, 2014 I suggest you place your question also in the Beth OBSE thread. Some experienced C pros discuss this kind of things there every once in a while. Link to comment Share on other sites More sharing options...
severs64 Posted June 21, 2014 Author Share Posted June 21, 2014 Thanks, QQuix. It ended up being dumbity on my part, not being appropriately careful using global variables in a thread. Fixed now, thanks though. Link to comment Share on other sites More sharing options...
Recommended Posts