RMMV JavaScript Unofficial Bugfix Snippets

Kaliya

// Caffeine Overload
Developer
Joined
Nov 1, 2015
Messages
506
Reaction score
566
First Language
English
Primarily Uses
RMMV
You mentioned walk speed, but I don't see that that bit of code has anything to do with walk speed specifically (rather, walk-speed changing would be a symptom of the problem, but there would be many other symptoms as well). Can you clarify/confirm? Do you have a link to the original thread?
Basically because the game engine/the game doesn't run at a fixed tick rate, or frame rate the game logic (movement,event processing,input processing, etc) will run at whatever FPS you are running it  at. So if you have a 144hz monitor, the game will run at 2-4 times the speed of a normal game, and everything will be faster, not just movement. That may seem like its not so bad till you get to where EVERYTHING runs faster, so all your events that you have made too run at a specific "Time" and such also don't execute at the speed you'd like them too because of someones faster computer, which can inherently ruin your game for them. I don't think this is the original thread, but the introduction to this plugin explains it more: http://forums.rpgmakerweb.com/index.php?/topic/50709-fluidtimestep-fix-the-game-speed/?hl=144hz
 

Ramiro

Now with an army of Mecha-Ralphs!
Veteran
Joined
Aug 5, 2015
Messages
858
Reaction score
364
First Language
Spanish
Omg, this is a horrible bug, when you clean the cache, it never releases the webGL objects attached to the bitmaps, so memory leaks filled with webGL textures on VRAM...

ImageManager.clear = function() {  this._cache = {}};It should be something like:

Code:
ImageManager.clear = function() {  for (var p in this._cache) {     if (this._cache.hasOwnProperty(p) && this._cache[p] instanceof Bitmap) {      if (this._cache[p].baseTexture) this._cache[p].baseTexture.destroy();     }  }  this._cache = {}};
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
40,846
Reaction score
14,039
First Language
English
Primarily Uses
RMMV
thanks. Logged.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
40,846
Reaction score
14,039
First Language
English
Primarily Uses
RMMV
no, I couldn't find it. But then Ace had a Cache.clear method that was also never called. The method is there to use if we ever want it for any reason.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
40,846
Reaction score
14,039
First Language
English
Primarily Uses
RMMV
The point of the cache is to reduce loading times. By keeping everything in memory, the only delay is the very first time each resource is accessed. It would defeat the purpose of having a cache if you cleared it.


You either have memory issues (which is only an issue now that we're playing on mobile devices), or you have loading issues. It's a case of "choose one".
 
Last edited by a moderator:

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
40,846
Reaction score
14,039
First Language
English
Primarily Uses
RMMV
You're acting like mobile not working properly would be not that bad
I am not sure how you draw that conclusion from what I said. What I said was that the memory issues due to keeping everything in cache are only a problem now because we HAVE the ability to export to devices that have very low memory.


That says nothing at all about whether it's important or not. It says it wasn't important before because we couldn't do it before, which potentially explains why "keep everything in cache" was an acceptable solution in previous makers.


I have already stated, either in this thread or in another, that the ideal would be to keep track of how many times each resource is used, to update that when the resource is no longer used, and to remove it from cache when the use count hits zero. And that it would require a fairly significant rewrite of the engine because there is currently no updating of resource counts when a scene is closed or a resource is "let go", as well as the added complexities due to resources being copied or cloned rather than just used straight out of cache.


I wouldn't do it via ImageManager.clear() though, as I don't believe fixing one problem by causing another is an acceptable trade-off.


So some time ago I already said what you said - that the way it's handled is not good for mobile devices. Please stop putting words in my mouth. What you said is just not true.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
40,846
Reaction score
14,039
First Language
English
Primarily Uses
RMMV
If you read through the threads here, you will find there are many more complaints about delays due to loading-on-demand than there are about crashes due to memory overflow.


You've given me an idea, but this probably isn't the thread to talk about it. Let me see what I can do ...
 

eivl

Villager
Member
Joined
Jun 12, 2013
Messages
20
Reaction score
1
First Language
English
Primarily Uses
I have written about this somewhere else in October, but TL;DR is that you need to to one of the following, reduce the cache (or clear it) or decouple the prototype chain of unused objects in memory so that it will be picked up by the garbage collector. 

I would be happy to assist since this is something i normally do in my day job ;)
 
Joined
Apr 30, 2012
Messages
216
Reaction score
35
First Language
Spanish
Primarily Uses
I dont know if this is important,but a Japanese scripter has done a patch for fix the memory leak issue. But i dont have permission for post it.
 

ArkDG

Veteran
Veteran
Joined
May 26, 2013
Messages
143
Reaction score
48
First Language
portuguese
Primarily Uses
Can you post the scripter page link or a place from where to see and download it?
 

lucia116

Villager
Member
Joined
Feb 3, 2016
Messages
15
Reaction score
1
First Language
japan
Primarily Uses
Omg, this is a horrible bug, when you clean the cache, it never releases the webGL objects attached to the bitmaps, so memory leaks filled with webGL textures on VRAM...




ImageManager.clear = function() {  this._cache = {}};


It should be something like:




ImageManager.clear = function() {  for (var p in this._cache) {     if (this._cache.hasOwnProperty(p) && this._cache[p] instanceof Bitmap) {      if (this._cache[p].baseTexture) this._cache[p].baseTexture.destroy();     }  }  this._cache = {}};

Do I need to modify any file?
Please tell us.
 

HeroicJay

Veteran
Veteran
Joined
Jun 23, 2014
Messages
322
Reaction score
177
First Language
English
Primarily Uses
RMMV
Actors acting randomly will ALWAYS target enemy/actor #1. Always always always. When enemy #1 is dead, they will always target enemy #2, and so on down the line. They will not actually hit random targets. Here's the fix:


Game_Action.prototype.decideRandomTarget = function() {
var target;
if (this.isForDeadFriend()) {
target = this.friendsUnit().randomDeadTarget();
} else if (this.isForFriend()) {
target = this.friendsUnit().randomTarget();
} else {
target = this.opponentsUnit().randomTarget();
}
if (target) {
this._targetIndex = target.index();
} else {
this.clear();
}
};

Code:
Game_Action.prototype.evaluate = function() {
    var value = 0;
    this.itemTargetCandidates().forEach(function(target) {
        var targetValue = this.evaluateWithTarget(target);
        if (this.isForAll()) {
            value += targetValue;
        } else if (targetValue > value) {
            value = targetValue;
            this._targetIndex = target.index();
        }
    }, this);
    value *= this.numRepeats();
    if (value > 0) {
        value += Math.random();
    }
    return value;
};


The difference with the default functions? No () after "target.index". That's not a property; it's a function!
 
Last edited by a moderator:

Latest Threads

Latest Posts

Latest Profile Posts

Chilling out while toodling around someone's painstaking Minecraft recreation of Disneyland. It is mind-boggling and probably as close as I'll ever be to going.
>Testing with fonts change.
>Tries installing a plugin. Doesn't work.
>Tries changing the plugin commands. Doesn't work.
>Tries installing another plugin. Doesn't work.
>Changes a few more plugin commands. Doesn't work.
>Goes directly to the gamefont file and changes the src. Works.

YYEEEAAAAHHHAAAA

Perseverance is key, bois and girls.
What Reviews say on RPG Maker MZ?
Looking back at some sketches, and game design documents on my PC dated summer of 2015. I started development with the release of MZ, but in 2015, I felt a strong desire to make a game out of the blue. I remember feeling sad for no apparent reason, and all these ideas rushed into my head. Now that I think about it, since that day, everything has become easier to do on my PC . . . it’s very creepy.
Everything's going to be alright! We're all in this together. <3

Forum statistics

Threads
107,806
Messages
1,032,349
Members
139,952
Latest member
4kWave
Top