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

getpartymember upgrade #3305

Merged

Conversation

jasonch35
Copy link
Contributor

Pull Request Prelude

Changes Proposed

Hi, I'd like to share my version of the getpartymember script command, similar to getunits.

This updated version no longer uses global temporary variables, which are prone to being overwritten, especially when multiple players call the function simultaneously. Instead, it requires the scripter to declare an array as an argument in the 3rd parameter of the command.

Additionally, this change introduces the following constants: PT_MEMBER_NAME, PT_MEMBER_CHARID, and PT_MEMBER_ACCID. The function now also returns the size of the party.

Sample usage:

.@count = getpartymember(getcharid(CHAR_ID_PARTY), PT_MEMBER_NAME, .@name$);
for (.@i = 0; .@i < .@count; .@i++) {
	consolemes(CONSOLEMES_DEBUG, ""+.@name$[.@i]+"");
}

The existing script will be deprecated, but I will gladly update all current NPC scripts to use this new version if approved. I can apply similar updates to getguildmember and getmobdrops as well.

I think this approach aligns more closely with Herc's style.

Issues addressed:
Wrong data when multiple players call the command.

getpartymember(<party_id>, <type>, <array>);
Will now accept any array as argument
Value returned is the member count
Uses constants:
PT_MEMBER_NAME
PT_MEMBER_CHARID
PT_MEMBER_ACCID

sample usage:
.@count = getpartymember(getcharid(CHAR_ID_PARTY, PT_MEMBER_NAME, .@name$);
Copy link
Member

@MishimaHaruna MishimaHaruna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, and thank you for sharing! Please do update the scripts when you have time to do so (in a separate commit).

I think it looks good. Even if still in draft, I went alread and added some review comments. Please have a look at them.

src/map/script.c Outdated Show resolved Hide resolved
src/map/script.c Outdated Show resolved Hide resolved
src/map/script.c Show resolved Hide resolved
@MishimaHaruna MishimaHaruna added this to the Release v2024.08 milestone Jul 30, 2024
@jasonch35 jasonch35 marked this pull request as ready for review July 31, 2024 04:52
Copy link
Member

@MishimaHaruna MishimaHaruna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Will you update the scripts (luckily there aren't a lot of calls to this command, I only see 16) and the script_commands.txt documentation?

@MishimaHaruna MishimaHaruna changed the base branch from master to getpartymember August 31, 2024 01:46
@MishimaHaruna MishimaHaruna merged commit 5a38450 into HerculesWS:getpartymember Aug 31, 2024
116 of 346 checks passed
@MishimaHaruna MishimaHaruna mentioned this pull request Aug 31, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants