Please login or register.

Login with username, password and session length
Advanced search  

News:

For WME related articles and tutorials visit WME Resource Center.

Author Topic: Plugin question  (Read 5734 times)

0 Members and 1 Guest are viewing this topic.

Spellbreaker

  • Supporter
  • Frequent poster
  • *
  • Karma: 4
  • Offline Offline
  • Gender: Male
  • Posts: 376
    • View Profile
    • Apeiron Studios
Plugin question
« on: June 23, 2011, 10:45:17 AM »

Hey there.

I am having a strange behavior with a plugin I created. The plugin uses serialization to store some information. When i now load a saved game, the serialize function gets called, the values gets loaded, everything fine. But after that, the plugin destructor is called. But then, the plugins methods still get called. I wonder why that happens, since in the destructor i delete some stuff the plugin needs to work properly.

Are there maybe two objects alive at the same time? I am creating the plugin object in the game.script file as a global.

Sincerly,

Spellbreaker
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Plugin question
« Reply #1 on: June 23, 2011, 11:57:30 AM »

Well I think it can actually happen that during load a new object is created before the old one is destroyed, that's "by design".
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Spellbreaker

  • Supporter
  • Frequent poster
  • *
  • Karma: 4
  • Offline Offline
  • Gender: Male
  • Posts: 376
    • View Profile
    • Apeiron Studios
Re: Plugin question
« Reply #2 on: June 23, 2011, 03:31:57 PM »

That means it's not possible to serialize Data with a Plugin? Because the object is destroyed after the data has been loaded from the savegame, which is quite senseless :) Or could the problem be, that WME destroys the new object instead of the old one? It should be possible to use the serialization from within a plugin...

cheers
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Plugin question
« Reply #3 on: June 23, 2011, 03:44:48 PM »

Quote
That means it's not possible to serialize Data with a Plugin? Because the object is destroyed after the data has been loaded from the savegame, which is quite senseless
Err, what? Remember that's a completely different object.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Spellbreaker

  • Supporter
  • Frequent poster
  • *
  • Karma: 4
  • Offline Offline
  • Gender: Male
  • Posts: 376
    • View Profile
    • Apeiron Studios
Re: Plugin question
« Reply #4 on: June 23, 2011, 03:52:18 PM »

Okay again :)

I run my plugin using the vc debugger step by step, the following happens when loading a game :

- Constructor is called ( calling bass_init(); just for info )
- Serialize is called ( loading filenames and other stuff from the savegame, and starting playing the music fiiles, which actually works until .... )
- Destructor is called ( calling bass_free(); now the plugin does not work anymore ( because of the BASS_Free() I guess ).


greets

Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Plugin question
« Reply #5 on: June 23, 2011, 04:20:02 PM »

Yes, but construction and deserialization is one object (the one that's being recreated from the saved game), destruction is other object (the one that existed before you decided to load a saved game).
Normally this is not a problem, but in your case you need to manage external resource (-> BASS), so for you this misorder is a problem (because the new instance creates BASS, which is immediately destroyed together with the old instance). What if you don't destroy BASS at all, and only destroy the streams? Is it legal to call BASS initialization multiple times?
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Spellbreaker

  • Supporter
  • Frequent poster
  • *
  • Karma: 4
  • Offline Offline
  • Gender: Male
  • Posts: 376
    • View Profile
    • Apeiron Studios
Re: Plugin question
« Reply #6 on: June 23, 2011, 07:45:10 PM »

I can call the BASS Initialization multiple times, thats not a problem (it would simply spit out an error code saying that it's already initialized, but everything would work as expected). But since I cannot call BASS_Free() when the game quits, what happens? Can it be a serious problem?
Logged

Spellbreaker

  • Supporter
  • Frequent poster
  • *
  • Karma: 4
  • Offline Offline
  • Gender: Male
  • Posts: 376
    • View Profile
    • Apeiron Studios
Re: Plugin question
« Reply #7 on: June 23, 2011, 07:55:38 PM »

Ahhh couldn't I simply write a shutdown method as class member and put it into the on "QuitGame" Event in the game.script? Shouldn't that do the trick?
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Plugin question
« Reply #8 on: June 23, 2011, 08:11:27 PM »

Yeah, good idea. That will work.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Spellbreaker

  • Supporter
  • Frequent poster
  • *
  • Karma: 4
  • Offline Offline
  • Gender: Male
  • Posts: 376
    • View Profile
    • Apeiron Studios
Re: Plugin question
« Reply #9 on: June 23, 2011, 09:49:20 PM »

Just for the records - works perfectly :)

Thanks for all the help again ;)
Logged
 

Page created in 0.018 seconds with 24 queries.