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

add Card.IsTextMention #579

Closed
wants to merge 2 commits into from
Closed

add Card.IsTextMention #579

wants to merge 2 commits into from

Conversation

salix5
Copy link
Collaborator

@salix5 salix5 commented Apr 18, 2024

@mercury233 @purerosefallen
ocgapi:
new API

extern "C" DECL_DLLEXPORT void set_mention_handler(mention_handler f);
//Set the mention_handler.
bool mention_handler(uint32 text_code, uint32 name_code)
//Check if the text of `text_code` mentions the name of `name_code`.

new function:

bool is_mention(uint32 text_code, uint32 name_code) {
	return thandler(text_code, name_code);
}

new Lua function

---Check if the text of this card mentions the name of `code`.
---@return boolean
---@param code integer
function Card.IsTextMention (code) end

It is the basic version.
It can only check the card name which is NOT a setname.
The card name which is also a setname can be checked by the old Auxiliary.IsCodeListed.

@purerosefallen
Copy link
Collaborator

Personally I don't like doing in this way, for the following reasons.

  1. String searching has a complexity of O(n^2) which slows server down being a regular condition check.
  2. This changes server deployment a lot, requiring to upload strings.conf as well. Btw is this commit tested on Mac / Linux? I doubt wstring works on those OSes. This is important because our server deploys on Linux.
  3. This also consumes server memory a lot, requiring to load every strings from cdb and strings.conf to memory. It's 7 MB in size for the current cards.cdb file. We could have 500 duels at once in our most popular servers, so if loading all of them, it would consume around 3.5 GB more memory, which is not acceptable.

@salix5 salix5 closed this Apr 20, 2024
@salix5 salix5 deleted the patch-mention branch June 22, 2024 16:29
@salix5 salix5 restored the patch-mention branch June 22, 2024 16:30
@salix5 salix5 deleted the patch-mention branch February 3, 2025 13:45
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