Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Losing !togglegm upon zoning #5636

Closed
3 tasks done
Mortalelite opened this issue May 6, 2024 · 18 comments · Fixed by #5648
Closed
3 tasks done

🐛 Losing !togglegm upon zoning #5636

Mortalelite opened this issue May 6, 2024 · 18 comments · Fixed by #5648
Labels
bug Something isn't working

Comments

@Mortalelite
Copy link
Contributor

Mortalelite commented May 6, 2024

I affirm:

  • I understand that if I do not agree to the following points by completing the checkboxes my issue will be ignored.
  • I have read and understood the Contributing Guide and the Code of Conduct.
  • I have searched existing issues to see if the issue has already been opened, and I have checked the commit log to see if the issue has been resolved since my server was last updated.

OS / platform the server is running (if known)

Windows 10

Branch affected by issue

base

Steps to reproduce

When you have !togglegm and you zone it will be removed. You are able to toggle it back on, but once zone again it is removed. This happens on current char.

If you create a new char it does stay when you zone. If you toggle off !togglegm and zone it comes back on

Expected behavior

Keep !togglegm upon zoning

@Mortalelite Mortalelite added the bug Something isn't working label May 6, 2024
@Mortalelite
Copy link
Contributor Author

Mortalelite commented May 6, 2024

I found the issue to be within the char_flags.sql

Your current char does not get a flag unless you manually insert a line for it. But if you set gmModeEnable to 1 it stays upon zoning.

If you create a new char and it is marked as a GM, then when you toggle it on. It does stay upon zoning, but once toggle off it stays.

You have go into char_flags and change from 1 to 0 to disable gmModeEndable

@WinterSolstice8
Copy link
Member

"manually insert a line" -- can you elaborate further? are there sql errors in map?

@Mortalelite
Copy link
Contributor Author

If you are in the DB and then go to char_flags and right click to insert row and no errors within map.

@WinterSolstice8
Copy link
Member

It sounds like you didn't run the migration?

cur.execute("INSERT INTO char_flags (charid) SELECT charid FROM chars ON DUPLICATE KEY UPDATE char_flags.disconnecting = char_flags.disconnecting;");

@Mortalelite
Copy link
Contributor Author

I ran everything suppose to. But even on a new char when you do !togglegm and turn it off and zone, it auto keeps at 1 instead turning to 0

@WinterSolstice8
Copy link
Member

If you had to insert that row that means the migration didn't run, the query above inserts a new row for all pre-existing characters, and new characters get an entry on that table here:

if (_sql->Query("INSERT INTO char_flags(charid) VALUES(%u) ON DUPLICATE KEY UPDATE disconnecting = disconnecting", charid) == SQL_ERROR)

@Mortalelite
Copy link
Contributor Author

Well I would not know how it did run when I updated DB with py -3 dbtool.py update and did all the migration at that time. So how would I run that then.

@Mortalelite
Copy link
Contributor Author

I ranpy -3 dbtool.py just incase and here what I got

Capture

@WinterSolstice8
Copy link
Member

hmm... that's really weird. I don't have an explanation for why your char_flags wasn't populated then

@WinterSolstice8
Copy link
Member

You should run this query on your db just in case:
INSERT INTO char_flags (charid) SELECT charid FROM chars ON DUPLICATE KEY UPDATE char_flags.disconnecting = char_flags.disconnecting;

@WinterSolstice8
Copy link
Member

I think I see the bug. it looks like db.commit() isn't called in the migration, I missed it. Apparently this could mean the query just didn't execute. I tested this on Linux, which may behave differently.

Thanks for the report, you 100% should run the above query.

@Mortalelite
Copy link
Contributor Author

I ran the query. Just booting back up the server to test it

@Mortalelite
Copy link
Contributor Author

Ok it is semi working. When you have !togglegm on and turn off before zoning. It comes back on

@WinterSolstice8
Copy link
Member

I'll look into it after I get home from work

@Mortalelite
Copy link
Contributor Author

Ok no worries. Thanks for looking into it. It is something with the gmModeEnable staying as 1 instead going to 0. The gmHiddenEnable is working like it suppose to within char_flags.

@WinterSolstice8
Copy link
Member

I did a 5 second check (still on my lunch break)

in charutils::SaveCharGMLevel()
try updating
_sql->Query(Query, "char_flags", "gmModeEnabled =", PChar->m_GMlevel >= 3 ? 1 : 0, PChar->id);
to
_sql->Query(Query, "char_flags", "gmModeEnabled =", PChar->visibleGmLevel >= 3 ? 1 : 0, PChar->id);

@Mortalelite
Copy link
Contributor Author

Ok that is working

@Mortalelite
Copy link
Contributor Author

Should I make a PR for this or wait to see if come up with another fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants