Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

gainGP issue

Newbie Spellweaver
Joined
May 24, 2017
Messages
57
Reaction score
1
Hello everyone,

So lately there's been this issue that's been driving me nuts, so basically everytime I gain guild points from any NPC I'll basically only get that x amount and it will not increase until the next server restart.

For example: If I finish a quest and get 2 guild points and then re-do the quest again and gain 2 more guild points, it will just register as 2 guild points in the guild meaning the points won't add up and will just stay as 2.

However if I restart the server and do the quest again it will add up and become 4, and the same goes for another server restart. I hope that made sense. :/

The weird thing is that I've compared every single gaingp method with HeavenMS/MoopleDEV and they are basically the same which is weird...so then I thought it might have to do with wrong op codes but my GUILD_OPERATION send/recv codes are correct (I think?)

These are my opcodes and the gaingp method in MapleGuild.java for reference:
PHP:
public void gainGP(int amount) {        
this.gp += amount;        
this.writeToDB(false);        
this.guildMessage(MaplePacketCreator.updateGP(this.id, this.gp));    
}

Sendops:
Code:
GUILD_OPERATION: 0x41

Recvops:
Code:
GUILD_OPERATION: 0x7E

I hope someone can shed some light on this as I am very lost on what is going on here. Thanks.
 
Mythic Archon
Joined
Jul 2, 2013
Messages
723
Reaction score
70
Just to be safe, set a break point and check whether the value of gp has incremented properly. You're also saving to the database right away (I assume that is what writeToDB is for and the false argument is because you probably have two or more occasions where you writeToDB so you have parts of the save function you don't want or do want executed), so check your database for the value of gp. If those are both okay, your update packet isn't doing it's job.
 
Upvote 0
Newbie Spellweaver
Joined
May 24, 2017
Messages
57
Reaction score
1
Just to be safe, set a break point and check whether the value of gp has incremented properly. You're also saving to the database right away (I assume that is what writeToDB is for and the false argument is because you probably have two or more occasions where you writeToDB so you have parts of the save function you don't want or do want executed), so check your database for the value of gp. If those are both okay, your update packet isn't doing it's job.

I've actually checked those methods and they are the same as how every source handles it, also I've checked with my updateGP and it's also the same as well.
PHP:
public static MaplePacket updateGP(int gid, int GP) {        
MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();    
 mplew.writeShort(SendPacketOpcode.GUILD_OPERATION.getValue());   
 mplew.write(0x48);        
 mplew.writeInt(gid);       
 mplew.writeInt(GP);  
 return mplew.getPacket();  
  }
 
Upvote 0
Mythic Archon
Joined
Jul 2, 2013
Messages
723
Reaction score
70
Because you are uncertain to what the issue could be, you should debug to eliminate all the possibilities. You have multiple possibilities for what could be the issue. Let's assume your updateGP works, since you say it updates the first time around. That leaves you with your gainGP. Unless your saveToDB function is reloading the guild after you save it, the arguments being passed into updateGP is gp + argument passed in. So this leaves you with three possibilities:

1. saveToDB isn't working as intended.
2. Argument passed in for gainGP isn't correct.
3. Something is altering GP elsewhere (so using it or removing it).

In all three cases, debugging will tell you what is going on and where your issue is.

Best of luck!
 
Upvote 0
Newbie Spellweaver
Joined
May 24, 2017
Messages
57
Reaction score
1
Because you are uncertain to what the issue could be, you should debug to eliminate all the possibilities. You have multiple possibilities for what could be the issue. Let's assume your updateGP works, since you say it updates the first time around. That leaves you with your gainGP. Unless your saveToDB function is reloading the guild after you save it, the arguments being passed into updateGP is gp + argument passed in. So this leaves you with three possibilities:

1. saveToDB isn't working as intended.
2. Argument passed in for gainGP isn't correct.
3. Something is altering GP elsewhere (so using it or removing it).

In all three cases, debugging will tell you what is going on and where your issue is.

Best of luck!

As I've mentioned before, I've checked everywhere that has to do with gp and compared it with other sources and it was the same. That's why this issue is very odd to me. :/
 
Upvote 0
Mythic Archon
Joined
Jul 2, 2013
Messages
723
Reaction score
70
Just because it's the same as another source doesn't mean it works. You still need to debug to see where the issue is or is coming from.
 
Upvote 0
Newbie Spellweaver
Joined
May 24, 2017
Messages
57
Reaction score
1
Just because it's the same as another source doesn't mean it works. You still need to debug to see where the issue is or is coming from.

The sources that I've compared with actually had guild points working and are the same functions/methods as the source I'm using. The issue is more with GP only updating again after server restart. There are also alot of threads detailing this issue but none of them have found a fix.

Here's 2 of them:
http://forum.ragezone.com/f566/guild-1059361/
http://forum.ragezone.com/f566/guild-arent-updating-928034/
 
Upvote 0
Newbie Spellweaver
Joined
May 24, 2017
Messages
57
Reaction score
1
---Update

2 things I've noticed...

1. If a member accepts a guild invite and joins the console will have a "Unhandled GUILD_OPERATION packet: All: 7E 00 00"

2. If you gain guild points it will only show up for you only, for example if you gained 2 guild points and you opened the guild menu you will see that the guild has a total of 2 guild points. However if you go on your 2nd character that is in the guild he will see that the guild has a total of 0 guild points.

I'm not sure what to do next...
 
Upvote 0
Junior Spellweaver
Joined
Sep 16, 2017
Messages
156
Reaction score
36
1. If a member accepts a guild invite and joins the console will have a "Unhandled GUILD_OPERATION packet: All: 7E 00 00"

(Given the opcode I'll go ahead and assume you're working on v83)

If this is the packet you're receiving, there's definitely something up somewhere. Apart from 7E 00, the opcode, a correct Guild joining packet should have a 0x6 byte, and that should be followed by the Guild ID and the Character ID passed as int values. the relevant code portion in HeavenMS.

It's as if the characters are somehow joining clone versions of the same guild (which would be why only you can see the GP you obtain, for example).

Is the packet altered in some way, before being processed?
 
Upvote 0
Newbie Spellweaver
Joined
May 24, 2017
Messages
57
Reaction score
1
(Given the opcode I'll go ahead and assume you're working on v83)

If this is the packet you're receiving, there's definitely something up somewhere. Apart from 7E 00, the opcode, a correct Guild joining packet should have a 0x6 byte, and that should be followed by the Guild ID and the Character ID passed as int values. the relevant code portion in HeavenMS.

It's as if the characters are somehow joining clone versions of the same guild (which would be why only you can see the GP you obtain, for example).

Is the packet altered in some way, before being processed?

Yes it's v83, I actually somehow fixed the unhandled packet yesterday by adding the "case 0x00" part in GuildOperationHandler. Also, for some odd reason it also fixed the part where guild points weren't updated to guild members at the same time.

However, another issue popped up where let's say I gain 2 guild points and it's shown in the guild that I gained 2 guild points and then after that I change channel or relog then it will be shown as 0 guild points in the guild menu but if you look at the SQL it will show as 2 guild points?

I'm really lost because at this point I've tried testing everything I can think of.
 
Upvote 0
Junior Spellweaver
Joined
Sep 16, 2017
Messages
156
Reaction score
36
Mmm.
I'm a bit confused though: how does the server know which guild to add the character to? If the packet that's passed is only 7E 00 00, no info is sent about the guild or the character that's trying to join.

Is the client itself modified aswell, so that that data is not included in the packet anymore?
 
Upvote 0
Newbie Spellweaver
Joined
May 24, 2017
Messages
57
Reaction score
1
Mmm.
I'm a bit confused though: how does the server know which guild to add the character to? If the packet that's passed is only 7E 00 00, no info is sent about the guild or the character that's trying to join.

Is the client itself modified aswell, so that that data is not included in the packet anymore?


Previously when I got the "Unhandled Packet" error it actually added the character who was invited to the guild with no issue, it only occured when you accepted the invite so I'm guessing it was more of a case of a missing packet in the guildoperationhandler? As far as I know this update guild points issue only occurs in TiredStory's source.
 
Upvote 0
Junior Spellweaver
Joined
Sep 16, 2017
Messages
156
Reaction score
36
My bad, after checking the packet for the Guild response in the client I realized that I didn't know that 7E 00 00 is what's sent for a successful Guild joining by the joining character's client.

I'll take a better look tomorrow about the issue, at a first glance there doesn't seem to be anything weird going on, but I must be overlooking something.
 
Upvote 0
Mythic Archon
Joined
Jul 2, 2013
Messages
723
Reaction score
70
Are adding guild points and adding a player related?

Based on speculation, I want to add you actually (I think lol) have two separate issues. The first one is your guild points aren't always updating to the correct amount. The second one is not everyone can see your guild points.

For the first one, as an alternative to debugging.., can you actually perform something that would add guild points then log out and shut down the server immediately? I want to know if the amount is saved properly. If yes, can you do it again, gain any amount of positive points and shut down again. If the amount present is the sum of the two points, then you know your server is loading, handling and saving the guild points correctly. If it is not, then there is your issue. If the points are saving, I would check the packet data being sent to the client. It could be wrong.

For the second one, you just need to check if the packet being sent to the client is going out to every guild member and not just the guild member that completed the action, giving the guild the new amount of points.

I could be wrong about all this though, so lol.

Best wishes
 
Upvote 0
Newbie Spellweaver
Joined
May 24, 2017
Messages
57
Reaction score
1
My bad, after checking the packet for the Guild response in the client I realized that I didn't know that 7E 00 00 is what's sent for a successful Guild joining by the joining character's client.

I'll take a better look tomorrow about the issue, at a first glance there doesn't seem to be anything weird going on, but I must be overlooking something.

Are adding guild points and adding a player related?

Based on speculation, I want to add you actually (I think lol) have two separate issues. The first one is your guild points aren't always updating to the correct amount. The second one is not everyone can see your guild points.

For the first one, as an alternative to debugging.., can you actually perform something that would add guild points then log out and shut down the server immediately? I want to know if the amount is saved properly. If yes, can you do it again, gain any amount of positive points and shut down again. If the amount present is the sum of the two points, then you know your server is loading, handling and saving the guild points correctly. If it is not, then there is your issue. If the points are saving, I would check the packet data being sent to the client. It could be wrong.

For the second one, you just need to check if the packet being sent to the client is going out to every guild member and not just the guild member that completed the action, giving the guild the new amount of points.

I could be wrong about all this though, so lol.

Best wishes

I think detailing this issue with screenshots should give a more clear vision on what this issue actually does.

For this, I have used cm.getGuild().gainGP(2); and my GP was 0 from the start.

After using the command: (this is broadcasted to all guild members currently online)

After changing channel/cash shop: (in the MySQL database it will show as 2 GP not 0 as shown)

Using the command again after changing channel/cashshop: (2 again)

Keep in mind that in both in-game and in the MySQL database it will not go further than 2 guild points no matter how many times you gain it.


After this test if you restart the server and open up the guild menu you will see that you have 2 guild points and this 2 is treated the same way if you repeat the above test. I hope it's more clear now.
 
Upvote 0
Junior Spellweaver
Joined
Sep 16, 2017
Messages
156
Reaction score
36
What happens if you gain another two GP without having changed channel? Does it manage to raise to 4, and then return to 0 after you cc?
 
Upvote 0
Junior Spellweaver
Joined
Sep 16, 2017
Messages
156
Reaction score
36
Ok, let's see. Could you try to change your gainGP function, in MapleGuild.java, to this one:

Code:
public void gainGP(int amount) {
[B]    this.guildMessage(MaplePacketCreator.serverNotice(5, "Previous GP amount: " + gp));
[/B]    this.gp += amount;
    this.writeToDB(false);
    this.guildMessage(MaplePacketCreator.updateGP(this.id, this.gp));
[B]    this.guildMessage(MaplePacketCreator.serverNotice(5, "New GP amount: " + gp));[/B]}

The only difference is that we've added two Guild messages (bolded text) that should display the GP amount update.
The gp variable is supposed to exist as long as that MapleGuild object doesn't fall out of scope, so I'm curious to see whether the value is correctly updated atleast there.

I'd test the two interesting scenarios: 1) gaining GP two consecutive times without changing channels inbetween, and 2) gaining GP, changing channel, and gaining GP again.
 
Last edited:
Upvote 0
Mythic Archon
Joined
Jul 2, 2013
Messages
723
Reaction score
70
Check when and where the guild is saved to the database. There could be a case where you're saving the right amount of guild points, but you're not actually loading them. Default is 0, or 0 could even be hard coded for some reason. If this is the case,after you save and the guild object is reloaded, the GP could be reset to 0 for potential reasons mentioned above. Which would explain why adding guild points again is adding properly. If it is reset to 0 after being saved and points are being added again, what's happening is you're adding points on top of zero instead of your previously accumulated points, then saving over the previous save once the guild is being saved again.

Heh
 
Upvote 0
Newbie Spellweaver
Joined
May 24, 2017
Messages
57
Reaction score
1
Ok, let's see. Could you try to change your gainGP function, in MapleGuild.java, to this one:

Code:
public void gainGP(int amount) {
[B]    this.guildMessage(MaplePacketCreator.serverNotice(5, "Previous GP amount: " + gp));
[/B]    this.gp += amount;
    this.writeToDB(false);
    this.guildMessage(MaplePacketCreator.updateGP(this.id, this.gp));
[B]    this.guildMessage(MaplePacketCreator.serverNotice(5, "New GP amount: " + gp));[/B]}

The only difference is that we've added two Guild messages (bolded text) that should display the GP amount update.
The gp variable is supposed to exist as long as that MapleGuild object doesn't fall out of scope, so I'm curious to see whether the value is correctly updated atleast there.

I'd test the two interesting scenarios: 1) gaining GP two consecutive times without changing channels inbetween, and 2) gaining GP, changing channel, and gaining GP again.

I've done the two tests using what you have given me, both test included me starting with 0 Guild Points.

First test without changing channels:

Second test with changing channels:

Both had the same result.
 
Upvote 0
Back
Top