Beiträge von VegaS

    Sanii

    • if len(antiFlagNames) <= 0

    In programming, in all languages, a list/vector/map/array... never can have size lower than 0, just >= 0.

    If you want just to check the list if isn't empty, is enough to do it just with if antiFlagName, like a normal boolean, there no need check length of it if you don't use it.

    About your method of antiFlagNameLines isn't related with this structure what's here, and also is hard-core for non-sense in this case.

    This is just an advice, i hope you got it.


    @Bitte melden Sie sich an, um diesen Link zu sehen.

    You guys.. make things so complicated for a little thing, here we don't need two lists for non-sense, three for-loop and bla bla.

    I would do it like this:

    Bitte melden Sie sich an, um diesen Link zu sehen.


    Added C++ version, check the repository. (Bitte melden Sie sich an, um diesen Link zu sehen., Bitte melden Sie sich an, um diesen Link zu sehen.)

    C
    1. #include "cff.h"
    2. std::string text = CFF::format("Metin2", "green");
    3. std::string text = CFF::format(std::to_string(8000), "banana");
    4. std::string text = CFF::format(std::to_string(412.55), "red");
    5. std::string text = CFF::format("Pending", "#113355");
    6. std::string text = CFF::format("Item name:", "springgreen", CFF::FLAG_NEW_TAB) + CFF::format(pItemData->GetName(), "chocolate");
    7. std::vector<string> text = CFF::multi_format({"a", "b", "c"}, "red"); // text[0], text[1], text[2]

    The google translate doesn't translate very good your request, but from what i understand, that's what you want.


    • cmd_general.cpp
    C
    1. ACMD(do_lang_german)
    2. {
    3. // Datenbank senden über den befehl
    4. [..........]
    5. ch->ChatPacket(CHAT_TYPE_COMMAND, "RestartClient");
    6. }


    • root/game.py
    Python
    1. #"CloseSafebox" : self.CommandCloseSafebox,
    2. "RestartClient" : self.CommandRestartClient,
    3. #def CommandCloseSafebox(self):
    4. #self.interface.CommandCloseSafebox()
    5. def CommandRestartClient(self):
    6. os.system('start metin2client2.exe')
    7. app.Exit()

    And remove os.system & app.Exit from __Language_1.

    So, after the "query" has inserted, the client will be restarted and you don't need any time for respoding.

    Btw, i never would write something like that as a DirectQuery, your server will burn.

    What's the issue?

    Code
    1. SYSERR: Aug 22 18:36:42.624296 :: ReadEtcDropItemFile: No such an item (name: Èò»ö ´ó±â+) SYSERR: Aug 22 18:36:42.624379 :: Boot: cannot load ETCDropItem: locale/germany/etc_drop_item.txt


    Some people fixed it long time ago by replacing the column name from item_proto (which is korean) with vnum.


    Bitte melden Sie sich an, um diesen Link zu sehen.


    If you want to do it like this and don't want the source change (from below) or you don't have the source code of your game core, you can use a update query and copy the vnum to name just if the vnum from item_proto exists inside of mob_proto.drop_item by a specific mob.

    SQL
    1. UPDATE player.item_proto SET name = vnum
    2. WHERE vnum IN (SELECT drop_item FROM player.mob_proto WHERE drop_item >= 10);
    3. # Affected rows: 83
    4. # Time: 35.919ms

    How can i know where the items are dropped?

    So, the structure of etc_drop_item.txt is based on dropping a item with a probability from a specific mob where that mob have the item vnum attached in column mob_drop -> drop_item.

    SQL
    1. SELECT DISTINCT locale_name, vnum, drop_item FROM player.mob_proto where drop_item >= 10;
    locale_namevnumdrop_item
    Wolf10230028
    Alpha Wolf10330069
    Alpha Blue Wolf10530027
    Grey Wolf10630070

    How-To-Fix

    Default structure:


    item_proto.nameprob
    늑대발톱2.0
    늑대발톱+2.0
    늑대털2.0
    멧돼지의 어금니2.0


    With the fix you can use both of methods:


    item_proto.[name or vnum]prob
    300282.0
    300692.0
    300272.0
    멧돼지의 어금니2.0


    • Srcs/Server/game/src/item_manager_read_tables.cpp


    • Srcs/Server/common/service.h

    2019-04-16 14:54:48 Tuesday Bitte melden Sie sich an, um diesen Link zu sehen. - 345 additions and 160 deletions.

    • Added a check for attr types and values min - max.
    • You can't insert wrong bonuses into a specific item.
    • Eg. Add 2000 MAX_HP on your Sword+9, was possible, now not.
    • Eg. Add +500 INT to your shield, now there's a check for min-max value of player.item_attr Lv.1 - Lv.5 and your 500 INTvalue will be replaced with max value from lvl5 of bonus, like 12 (lv5), that happen with all the bonuses, same thing with the values lower than lvl1, like 5 HP_REGEN on your neck, when the minimum (lv1) is 10, the value will be replaced with 10.
    • If the bonus type can't be added into a specific item, the bonus will be ignored > deleted. (example: critical pct to armor)
    • Refactorized all the code and moved all features into Bitte melden Sie sich an, um diesen Link zu sehen..
    • C++11 or higher is required for checking attributes.

    Builtin Debug Formatter

    A simple debug class which is used for output the messages for debugging.
    The class doesn't need to be called, we've added the functions into built-in functions.
    The purpose was to ease the work of developers.

    What's the difference between them?

    • Using the new method:
    Python
    1. TraceError("str", 1, 4.0, (31, 22), [100, 200], True)
    2. Tracef("str", 1, 4.0, (31, 22), [100, 200], True)
    3. LogBox("str", 1, 4.0, (31, 22), [100, 200], True)
    4. sys_err("str", 1, 4.0, (31, 22), [100, 200], True)
    5. # No import needed, is a built-in function, you can call it everywhere.
    6. # The function sys_err or TraceError doing the same thing.
    7. # Allow to pass unlimited argument-lines, no data types check, can be everything you want: <int, float, string, tuple, list, boolean>.
    • Using the old method:
    Python
    1. import dbg
    2. dbg.TraceError("just_one_string_allowed")
    3. dbg.Tracef("just_one_string_allowed")
    4. dbg.LogBox("just_one_string_allowed")
    5. # Need to import the module dbg every time in every file where you want to use it.
    6. # Allow to pass just one argument-line which need to be string, otherwise nothing happen.

    Built-In-Functions:

    Built in or inbuilt function are that type of functions which are already defined or created in a program or in programming framework. User don’t need to create these type of functions. User or developer can directly use built in function by only call it. This function is built into an application and can it can be accessed by end-users with simply call it.

    How-It-Works:

    • TraceError(args) - function prints the given arguments to the text stream file syserr.txt
    • Tracef(args) - function prints the given arguments to the console window (screen) while executable is compiled in a debug mode.
    • LogBox(args) - function prints the given arguments to the dialog box that contains a system icon, a set of buttons, and a brief application-specific message, such as status or error information.
    • sys_err(args) - same as TraceError.

    How-To-Call-Ex :

    GitHub repository:

    Thanks to Bitte melden Sie sich an, um diesen Link zu sehen. for reports.

    Update (check the repository from first post, or Bitte melden Sie sich an, um diesen Link zu sehen. to see the last commit) :


    2019-04-12 02:31:18 Friday - 170 additions and 50 deletions.

    • Fixed unique items based on the real time.
    • Fixed unstackable items.
    • Fixed if item count overflow occured, then set it to maximum.
    • Added support for books. (check skill types, unknown skill), skill vnum need to be saved into socket0, (4=Aura of the Sword < player.skill_proto), if the skill vnum is unknown, there will be a random book based on pc races, excluded skills PASSIVE, GUILD, SUPPORT.
    • Added a to-do for ITEM_BLEND, check if apply_type exists in bonuses, check if apply_value/apply_duration is equal with grades (1/2/3/4/5) from settings, blend.txt
    • Added auto query.
    SQL
    1. # Random book
    2. INSERT INTO player.item_award(`login`, `vnum`, `count`, `mall`) VALUES ('account', 50300, 1, 1); # Specific book by skill vnum
    3. INSERT INTO player.item_award(`login`, `vnum`, `count`, `socket0`, `mall`) VALUES ('account', 50300, 1, 4, 1);


    Get bonus name from tooltip affect dictionary as string, ignore the %value% and function SA, SNA etc.
    Useful for some systems where you want to print just the bonus name, not with an percentage value.
    Ignore the dump.txt & dump_test.py, is just to test how function works.


    Just follow tutorial from localeInfo.py.

    How-To-use

    Python
    1. import localeInfo
    2. import item
    3. # FormatBonusNameString
    4. print localeInfo.FormatBonusNameString(item.APPLY_RESIST_SWORD)
    5. # FormatBonusNameDict
    6. for bonusIndex, bonusName in localeInfo.FormatBonusNameDict().iteritems():
    7. print '{:d}: {:s}'.format(bonusIndex, bonusName)

    GitHub repository:

    There are a lot of people which had problem with localeInfo because korean-characters and bad encoding, there's a clean file with refactored code.

    • Removed all the code which isn't used like korean characters < bad encoding(editors problem) and more checks.
    • Removed over 500 lines unused.
    • Removed function mapping(**kwargs) and use constructor of dict > dict(**kwarg) which is same (**kwarg let you take arbitrary number of keyword arguments).
    • Removed function CutMoneyString because is used just when locale is HongKong, CIBN.
    • Removed check IsYMIR from function LoadLocaleData which load locale as locale/ymir or locale/we_korea.
    • Removed GUILD_MARK_NOT_ENOUGH_LEVEL, GUILD_HEADQUARTER, GUILD_FACILITY, GUILD_OBJECT, MAP_TRENT02, MAP_WL, MAP_NUSLUCK, MAP_TREE2, LOGIN_FAILURE_WEB_BLOCK, LOGIN_FAILURE_BLOCK_LOGIN, CHANNEL_NOTIFY_FULL, now they're readed directly from locale_game.txt.
    • Removed declared global variables.
    • Removed checks for declaring LOCALE_FILE_NAME, FN_GM_MARK and use current path.
    • Removed korean functions/lists/dictionaries/characters GetAuxiliaryWordType, JOBINFO_DATA_LIST, dictSingleWord, dictDoubleWord, etc.
    • Removed unused things: locale mapping, 'all' list etc.
    • Removed IN_GAME_SHOP_ENABLE declaration, should be declared inside of constInfo directly.
    • Removed checks (locale path) - 949, 932 == app.GetDefaultCodePage(), IsHONGKONG, IsNEWCIBN() or IsCIBN10() from declaration of functions like (NumberToMoneyString, NumberToSecondaryCoinString, ...),now they're declared directly from old style (IsEUROPE() and not IsWE_KOREA() and not IsYMIR()).
    • Added custom string Bitte melden Sie sich an, um diesen Link zu sehen. instead of Bitte melden Sie sich an, um diesen Link zu sehen. (old-style).
    • Added new checks inside of LoadLocaleFile for security:
    • Check if token3 (token1=original_string, token2=return-string, token3=function) function name exist in our types (SA, SNA, SAA, SAN) then try to call it.
    • Check if string line have no tabs.

    Diff-checker: (856 Removals + 301 Additions)

    • Bitte melden Sie sich an, um diesen Link zu sehen.

    Bitte melden Sie sich an, um diesen Link zu sehen.:

    The code which you tried is called Python Inner Functions, and for use it you have to declare it inside of another function and call it.

    Delete it and put this:

    Thanks to Bitte melden Sie sich an, um diesen Link zu sehen. that he reminded me about bisection years. (i'll update the repository when i'll have a bit more free time)

    Leap Year

    • A normal year has 365 days.
    • A Leap Year has 366 days (the extra day is the 29th of February).
    Bitte melden Sie sich an, um dieses Bild zu sehen.Leap Years are any year that can be exactly divided by 4 (such as 2012, 2016, etc)
    Bitte melden Sie sich an, um dieses Bild zu sehen.except if it can be exactly divided by 100, then it isn't (such as 2100, 2200, etc)
    Bitte melden Sie sich an, um dieses Bild zu sehen.except if it can be exactly divided by 400, then it is (such as 2000, 2400)


    Python
    1. def GetRangeDaysMonth(calendarMonth):
    2. def GetBisectionYear(year):
    3. """ Provides support for maintaining a list in sorted order without having to sort the list after each insertion.
    4. Return True for leap years, False for non-leap years.
    5. """
    6. return year % 4 == 0 and (year % 100 <> 0 or year % 400 == 0)
    7. """ TODO-DONE: Fix the calendar range days-month if month is February and is a bisection year like 2016, 2020, 2024 ... """
    8. return Math.OFFSETS_MONTH_RANGE_TUPLE[calendarMonth - 1] + (calendarMonth == 2 and GetBisectionYear(Math.GetCurrentYear()))

    Output-test:

    Metin2 Color Formatter

    A simple class writted for Python and C++ which convert the param-values into an string by a specific color rgb as hexadecimals.

    • Color constants module:
      CSS
      1. https://www.webucator.com/blog/2015/03/python-color-constants-module/
      2. https://www.color-hex.com/color/ccffff
    • Python:
      Python
      1. from cff import CFF
      2. text = CFF.format('Metin2', 'green')
      3. text = CFF.format(8000, 'banana')
      4. text = CFF.format(412.55, 'red')
      5. text = CFF.format('Pending', '#113355')
      6. text = CFF.format('Item name:', 'springgreen', CFF.FLAG_NEW_TAB) + CFF.format(item.GetItemName(), 'chocolate')
      7. text = CFF.multi_format(('a', 'b', 'c'), 'red') # text[0], text[1], text[2]
    • C++:
      C
      1. #include "cff.h"
      2. std::string text = CFF::format("Metin2", "green");
      3. std::string text = CFF::format(std::to_string(8000), "banana");
      4. std::string text = CFF::format(std::to_string(412.55), "red");
      5. std::string text = CFF::format("Pending", "#113355");
      6. std::string text = CFF::format("Item name:", "springgreen", CFF::FLAG_NEW_TAB) + CFF::format(pItemData->GetName(), "chocolate");
      7. std::vector<string> text = CFF::multi_format({"a", "b", "c"}, "red"); // text[0], text[1], text[2]


    Github repository: