Register for your free account! | Forgot your password?

Go Back   elitepvpers > Popular Games > Metin2 > Metin2 Private Server > Metin2 PServer Guides & Strategies
You last visited: Today at 11:23

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[C++]FIX Cube_request_result_list: Too long cube result list text

Discussion on [C++]FIX Cube_request_result_list: Too long cube result list text within the Metin2 PServer Guides & Strategies forum part of the Metin2 Private Server category.

Reply
 
Old   #1
 
Exygo's Avatar
 
elite*gold: 0
Join Date: Mar 2014
Posts: 31
Received Thanks: 32
[C++]FIX Cube_request_result_list: Too long cube result list text

How to fix Cube_request_result_list: Too long cube result list text. ?


1. Go in cube.cpp

2. Replace:
Code:
        if (resultText.size() - 20 >= CHAT_MAX_LEN)
        {
            sys_err("[CubeInfo] Too long cube result list text. (NPC: %d, length: %d)", npcVNUM, resultText.size());
            resultText.clear();
            resultCount = 0;
        }
With this:

The problem was caused by a comparison between a negative number and a number
Exygo is offline  
Thanks
8 Users
Old 12/15/2015, 16:34   #2
 
elite*gold: 11
Join Date: Nov 2010
Posts: 1,709
Received Thanks: 3,828
Sorry, it's not this one xD never mind
.Shōgun is offline  
Old 12/15/2015, 22:25   #3
 
Isolation_'s Avatar
 
elite*gold: 0
Join Date: Dec 2014
Posts: 47
Received Thanks: 101
Hier noch eine Version:
Code:
        int resultsize = (resultText.size() < 20) ? (20 - resultText.size()) : (resultText.size() - 20);
        if (resultsize >= CHAT_MAX_LEN)
        {
            sys_err("[CubeInfo] Too long cube result list text. (NPC: %d, resultsize: %d, length: %d)", npcVNUM, resultsize, resultText.size());
            resultText.clear();
            resultCount = 0;
        }
So ganz ohne Werbung und etwas kürzer. Eigentlich kann man sich sogar die Variable schenken.
Isolation_ is offline  
Thanks
3 Users
Old 12/15/2015, 23:06   #4

 
elite*gold: 83
Join Date: Nov 2013
Posts: 2,891
Received Thanks: 2,764
Quote:
Originally Posted by Isolation_ View Post
Hier noch eine Version:
Code:
        int resultsize = (resultText.size() < 20) ? (20 - resultText.size()) : (resultText.size() - 20);
        if (resultsize >= CHAT_MAX_LEN)
        {
            sys_err("[CubeInfo] Too long cube result list text. (NPC: %d, resultsize: %d, length: %d)", npcVNUM, resultsize, resultText.size());
            resultText.clear();
            resultCount = 0;
        }
So ganz ohne Werbung und etwas kürzer. Eigentlich kann man sich sogar die Variable schenken.
Und kürzer ist besser?
Finde die Lesbarkeit sehr wichtig.
Deine Lösung finde ich besser zu lesen als die des erstellers, das ganze allerdings direkt im if block zu schreiben wäre meiner Meinung nach allerdings zu unübersichtlich.
rollback is offline  
Old 12/15/2015, 23:24   #5
 
fcsk_aim's Avatar
 
elite*gold: 100
Join Date: Dec 2014
Posts: 93
Received Thanks: 51
This fix it's useless.
I never had this in my syserr. :d
fcsk_aim is offline  
Old 12/15/2015, 23:43   #6

 
elite*gold: 83
Join Date: Nov 2013
Posts: 2,891
Received Thanks: 2,764
Quote:
Originally Posted by fcsk_aim View Post
This fix it's useless.
I never had this in my syserr. :d
My gf never got pregnant yet, why should i prevent?
rollback is offline  
Thanks
11 Users
Old 12/16/2015, 00:11   #7
 
fcsk_aim's Avatar
 
elite*gold: 100
Join Date: Dec 2014
Posts: 93
Received Thanks: 51
Quote:
Originally Posted by Seחsi View Post
My gf never got pregnant yet, why should i prevent?
There's nothing to prevent.
fcsk_aim is offline  
Old 12/16/2015, 00:23   #8
 
elite*gold: 0
Join Date: Dec 2015
Posts: 34
Received Thanks: 7
Quote:
Originally Posted by .Shōgun View Post
Sorry, it's not this one xD never mind
Sorry it's not this one -> xD <- Yes I think u r a bit mad today?
JeyMaker is offline  
Old 12/16/2015, 14:46   #9
 
elite*gold: 0
Join Date: Jan 2014
Posts: 268
Received Thanks: 373
Warum kam eigentlich keiner auf die Idee einfach eine int-Konvertierung zu benutzen? o_o
Lefloyd is offline  
Old 12/16/2015, 23:42   #10
 
Mashkin's Avatar
 
elite*gold: 44
Join Date: May 2010
Posts: 2,053
Received Thanks: 1,747
Quote:
Originally Posted by Lefloyd View Post
Warum kam eigentlich keiner auf die Idee einfach eine int-Konvertierung zu benutzen? o_o
And why not just do this - which will only fail if CHAT_MAX_LEN > MAX_INT - 20.
This is basic math.
Code:
if (resultText.size() >= CHAT_MAX_LEN + 20)
This inequation also shows that the original code is pretty much bullshit because the resultText is asserted to be 20 characters longer than CHAT_MAX_LEN.
In fact, resultText should be at maximum 20 characters shorter than CHAT_MAX_LEN.

The number 20 comes from the string to which resultText is appended which is assumed 14 + 6 = 20 characters in length.
In the code, the inserted numbers are assumed to be at maximum 5 and 1 characters long.
This might not be true for NPCs with vnums greater than 99.999 or(vnums ares of type WORD) more than 9 results.

Deducing 20 from CHAT_MAX_LEN thus does not safely determine the maximum length for resultText in some quite realistic cases, especially as resultCount and with it (on average proportionally) resultText's length grow.
Code:
ch->ChatPacket(CHAT_TYPE_COMMAND, "cube r_list %d %d %s", npcVNUM, resultCount, resultText.c_str());
// example: "cube r_list 20383 4 ..."
As becomes clear the function is actually broken in several ways, and your proposed change only removes one minor issue of it.

Your turn to fix this.
Mashkin is offline  
Old 12/17/2015, 21:16   #11
 
DasSchwarzeT's Avatar
 
elite*gold: 399
Join Date: Sep 2011
Posts: 5,323
Received Thanks: 3,937
Quote:
Originally Posted by Seחsi View Post
My gf never got pregnant yet, why should i prevent?

Don't even expect her to get pregnant.
DasSchwarzeT is offline  
Thanks
2 Users
Reply




All times are GMT +1. The time now is 11:24.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.