Jump to content

ridetpro

Banned
  • Posts

    106
  • Joined

  • Last visited

  • Days Won

    1
  • Feedback

    0%

Posts posted by ridetpro

  1. 1 oră în urmă, Syreldar a spus:

    I'll try very soon, thanks for the answers.

    It's probably not an error, it's a code problem.

    The client must be set to debug mode.

    d47c435855c89f72818533e49aa999b7.png

    Now change the launcher's output directory to the client's folder.

    abb3644dbf36e9b711d75991f6ebe768.png

    Now make this change in Debugging. (UserInterface -> Properties -> Debugging)

    66bd8c1284829f28346496ad791a9e23.png

    Open a new debugging instance:

    5504aa49294820b68556bc7fba29ad5b.png

     

    In this way, you will be able to see the call stack.

    Once the debug instance begins, log in to the client and wait for the crash. When the crash will appear you will be able to see callStack in visual studio ..

  2. Acum 18 ore, Mind Rapist a spus:

    Since I haven't got much experience (yet) with C++, dealing with more modern source structures can be really challenging for me, especially in Linux enviroments, where virtual help like Visual Studio and Intellisence are not available. It's been 2 months since I started discovering C++17 and with the help of the community (that's you guys) I learned a lot! One of the most challenging parts were converting an old-written source into a C++17 compilable project and some of the most struggling moments I had was converting the old function

    
    FuncQuery(std::bind1st(std::mem_fun(code...), this), "QUERY FOR DATABASE");

    into something acceptable towards the compiler. I ended up with the new bind from the std library:

    
    FuncQuery(std::bind(std::mem_fn(code), this, std::placeholders::_1), "QUERY FOR DATABASE");

    and lambda functions:

    
    FuncQuery([this](auto&& data) { return MyClass::MyVoid(data); }, "QUERY FOR DATABASE");

    Those conversions took place in a few files of the game source, but most of them were needed in guild.cpp. So my question is this: Is there something wrong with this conversion? Is there a more stable way for the specific game? And most important: Could this conversion be the reason for core/query/other errors or bugs?

    Let me know what you think!

    Best regards

    Try to donate exp intro guild after those conversions ?

  3. Acum 3 ore, Mind Rapist a spus:

    I did it. Crypto++ 700 compiles only in C++17. I tried again:

    
    cryptopp700# gmake clean
    cryptopp700# gmake 'CXXFLAGS+=-std=c++1z'
    cryptopp700# strip --strip-all libcryptopp.a
    cryptopp700# mv libcryptopp.a /usr/local/lib
    game/src# gmake clean
    game/src# gmake release

    Results were the same...

    Then you probably did not put the cryptopp7 headers in extern.

  4. Acum 48 minute, Mind Rapist a spus:

    I have this error:

    
    In file included from ./any_function.h:29:
    ./any_function.inc:98:3: error: no matching function for call to object of type
          '(lambda at guild.cpp:1023:39)'
                    held(func_arg);
                    ^~~~

    I am trying to pass this:

    
    DBManager::instance().FuncAfterQuery([this](auto&& data) { return this->RefreshCommentForce(data); }, (char*)ch->GetPlayerID(),

    Other methods have failed too (std::bind). I am compiling with C++17. Does anyone know what's wrong?

    void CGuild::AddComment(LPCHARACTER ch, const std::string &str)
    {
    	int player_id = ch->GetPlayerID();
    
    	if (str.length() > GUILD_COMMENT_MAX_LEN)
    	{
    		return;
    	}
    
    	char text[GUILD_COMMENT_MAX_LEN * 2 + 1];
    	DBManager::Instance().EscapeString(text, sizeof(text), str.c_str(), str.length());
    	DBManager::Instance().FuncAfterQuery(
    		[this, player_id] {this->RefreshCommentForce(player_id); },
    		"INSERT INTO guild_comment(guild_id, name, notice, content, time) VALUES(%u, '%s', %d, '%s', NOW())",
    		m_data.guild_id,
    		ch->GetName(),
    		(str[0] == '!') ? 1 : 0,
    		text);
    }

    Use std::function instead of any_function

    • Love 1
  5. // Intro pc_mount function from questlua_pc.cpp
    // Under LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
    // Add
    
    int CalcLastMoveSec = (get_dword_time() - ch->GetLastMountTime()) / 1000 + 0.5;
    
    if (CalcLastMoveSec < 1) // Replace 1 with seconds number.
    {
    	return 0;
    }

    8d79641cfda2bf7a40fbf62f568689e3.png

    • Love 1
  6. Acum 5 ore, charparodar a spus:

    BUMP

    Monsters aren't crashing the server anymore, but sometimes when players get poison on each other it crashs...

    
    # lldb game -c game.core
    (lldb) target create "game" --core "game.core"
    Core file '/usr/home/game/cores/channel1/game1/game.core' (i386) was loaded.
    (lldb) bt all
    * thread #1, name = 'game', stop reason = signal SIGSEGV
      * frame #0: game`CHARACTER::Damage(this=0x3eb47840, pAttacker=0x00000000, dam=<unavailable>, type=DAMAGE_TYPE_POISON) at char_battle.cpp:2121
        frame #1: game`long poison_event(event=LPEVENT @ 0x00000008, processing_time=0) at char_resist.cpp:68
        frame #2: 0x08491210 game`nBATTLE_ARENA_MAP + 16
      thread #2, name = 'game', stop reason = signal SIGSEGV
        frame #0: 0x2889d8e9 libc.so.7`__umtx_op + 5
        frame #1: 0x28889bac libc.so.7`sem_clockwait_np + 236
        frame #2: 0x28889c70 libc.so.7`sem_wait + 32
        frame #3: 0x0848ee98 game`CSemaphore::Wait(void) + 24
      thread #3, name = 'game', stop reason = signal SIGSEGV
        frame #0: 0x2889d8e9 libc.so.7`__umtx_op + 5
        frame #1: 0x28889bac libc.so.7`sem_clockwait_np + 236
        frame #2: 0x28889c70 libc.so.7`sem_wait + 32
        frame #3: 0x0848ee98 game`CSemaphore::Wait(void) + 24
      thread #4, name = 'game', stop reason = signal SIGSEGV
        frame #0: 0x2889d8e9 libc.so.7`__umtx_op + 5
        frame #1: 0x28889bac libc.so.7`sem_clockwait_np + 236
        frame #2: 0x28889c70 libc.so.7`sem_wait + 32
        frame #3: 0x0848ee98 game`CSemaphore::Wait(void) + 24
    (lldb)
    

     

    Pay someone to solve your shitty crash.

     

    bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // returns true if dead
    {
    	if (DAMAGE_TYPE_MAGIC == type)
    	{
    		dam = (int)((float)dam * (100 + (pAttacker->GetPoint(POINT_MAGIC_ATT_BONUS_PER) + pAttacker->GetPoint(POINT_MELEE_MAGIC_ATT_BONUS_PER))) / 100.f + 0.5f);
    	}
    
    // With
    
    bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type)
    {
    	if (pAttacker == NULL)
    	{
    		sys_err("CHARACTER::Damage");
    		sys_err("pAttacker is null, check your shitty server");
    		return false;
    	}
    
    	if (DAMAGE_TYPE_MAGIC == type)
    	{
    		dam = (int)((float)dam * (100 + (pAttacker->GetPoint(POINT_MAGIC_ATT_BONUS_PER) + pAttacker->GetPoint(POINT_MELEE_MAGIC_ATT_BONUS_PER))) / 100.f + 0.5f);
    	}

     

  7. https://chartio.com/learn/databases/how-does-indexing-work/

     

     

    What Does Indexing Do?

    Indexing is the way to get an unordered table into an order that will maximize the query’s efficiency while searching.

    When a table is unindexed, the order of the rows will likely not be discernible by the query as optimized in anyway and your query will therefore have to search through the rows linearly. That is to say the queries will have to search through every row to find the rows matching the conditions. You can imagine this would take a while. Looking through every single row is not very efficient.

    For example, the table below represents a table in a fictional datasource, that is completely unordered.

    COMPANY_ID UNIT UNIT_COST
    10 12 1.15
    12 12 1.05
    14 18 1.31
    18 18 1.34
    11 24 1.15
    16 12 1.31
    10 12 1.15
    12 24 1.3
    18 6 1.34
    18 12 1.35
    14 12 1.95
    21 18 1.36
    12 12 1.05
    20 6 1.31
    18 18 1.34
    11 24 1.15
    14 24 1.05

    If we were to run the following query:

    SELECT
    	company_id,
    	units,
    	unit_cost
    FROM
    	index_test
    WHERE
    	company_id = 18
    

    The database would have to search through all 17 rows in the order they appear in the table, basically from top to bottom, one at a time. So to search for all of the potential instances of the company_id number 18, the database must look through the entire table for all appearances of 18 in the company_id column.

    This will only get more and more time consuming as the size of the table increases. As the sophistication of the data increases what could eventually happen is that a table with one billion rows is joined with another table with one billion rows and now instead of taking x amount of time, the query now has to search through twice the amount of rows costing twice the amount of time.

    You can see how this becomes problematic in our ever data saturated world. Tables increase in size and searching increases in execution time.

    Querying an unindexed table, if presented visually, would look like this:

    figure 1

    What indexing does is sets up the column you’re search conditions are on in a sorted order to assist in optimizing query performance.

    With an index on the company_id column the table would then, essentially, “look” like this:

    COMPANY_ID UNIT UNIT_COST
    10 12 1.15
    10 12 1.15
    11 24 1.15
    11 24 1.15
    12 12 1.05
    12 24 1.3
    12 12 1.05
    14 18 1.31
    14 12 1.95
    14 24 1.05
    16 12 1.31
    18 18 1.34
    18 6 1.34
    18 12 1.35
    18 18 1.34
    20 6 1.31
    21 18 1.36

    Now, the database can search for company_id number 18 and return all the requested columns for that row then move on to the next row. If the next row’s comapny_id number is also 18 then it will return the all the columns requested in the query. If the next row’s company_id is 20, the query knows to stop searching and the query will finish.

    How does Indexing Work?

    In reality the database table does not reorder itself every time the query conditions change in order to optimize the query performance, that would be unrealistic. In actuality what happens is the index causes the database to create a data structure. The data structure type is very likely a B-Tree. The advantages of the B-Tree are numerous, the main advantage for our purposes is that it is sortable. When the data structure is sorted in order it makes our search more efficient for the obvious reasons we pointed out above.

    When the index creates a data structure on a specific column it is important to note that no other column is stored in the data structure. Our data structure for the table above will only contain the the company_id numbers. Units and unit_costwill not be held in the data structure.

    How Does the Database Know What Other Fields in the Table to Return?

    Database indexes will also store pointers which are simply reference information for the location of the additional information in memory. Basically the index holds the company_id and that particular row’s home address on the memory disk. The index will actually look like this:

    COMPANY_ID POINTER
    10 _123
    10 _129
    11 _127
    11 _138
    12 _124
    12 _130
    12 _135
    14 _125
    14 _131
    14 _133
    16 _128
    18 _126
    18 _131
    18 _132
    18 _137
    20 _136
    21 _134

    With that index, the query can search for only the rows in the company_idcolumn that have 18 and then using the pointer can go into the table to find the specific row where that pointer lives. The query can then go into the table to retrieve the fields for the columns requested for the rows that meet the conditions.

    If the search were presented visually, it would look like this:

    figure 1

    To Re-Cap

    • Indexing Adds a Data Structure with the Column that has the search conditions and a pointer

    • The Pointer is the address on the memory disk of the row with the rest of the information

    • The Data Structure Index is Sorted to optimize query efficiency

    • The Query looks for the specific row in the index, the index refers to the pointer which will find the rest of the information.

    • The Index reduces the number of rows the query has to search through from 17 to four.

    • Love 1
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.