From 820f822c271b91d6a55ed015a75d544d3604d2b9 Mon Sep 17 00:00:00 2001 From: Mark Klara Date: Thu, 19 Mar 2020 18:55:38 -0700 Subject: [PATCH] Update russian comments to english for the following dirs: (#427) - documentation/* - src/common/* - src/login/* - src/search/* The only directories that still need translations are: - src/map/* --- documentation/ZoneIDs.txt | 4 +- src/common/lua/lunar.h | 105 ++++++++++++------------- src/common/mmo.h | 42 +++++----- src/common/utils.cpp | 52 ++---------- src/common/utils.h | 12 +-- src/login/lobby.cpp | 88 ++++----------------- src/search/data_loader.cpp | 16 ++-- src/search/packets/auction_history.cpp | 20 +---- src/search/packets/auction_list.cpp | 16 ++-- src/search/packets/linkshell_list.cpp | 23 ++---- src/search/packets/party_list.cpp | 23 ++---- src/search/packets/search_list.cpp | 29 ++----- src/search/search.cpp | 76 ++++-------------- src/search/tcp_request.cpp | 54 +------------ 14 files changed, 171 insertions(+), 389 deletions(-) diff --git a/documentation/ZoneIDs.txt b/documentation/ZoneIDs.txt index 180740fe2f4..9c090fe5f4f 100644 --- a/documentation/ZoneIDs.txt +++ b/documentation/ZoneIDs.txt @@ -1,6 +1,4 @@ - -Список известных зон -List of known zones +List of known zones 0 - 00 - Tech Demo Area 1 - 01 - Phanauet Channel diff --git a/src/common/lua/lunar.h b/src/common/lua/lunar.h index e41f81b901e..b75b8b86f27 100644 --- a/src/common/lua/lunar.h +++ b/src/common/lua/lunar.h @@ -1,9 +1,9 @@ -#pragma once +#pragma once #include "lua.hpp" -/*Связыватель объектов C++ с объектами Lua*/ +/* Binds C++ objects to Lua objects. */ template class Lunar { - /*Структура инкапсулирования объекта C++ в объект Lua*/ + /* Structure for encapsulating a C++ object in a Lua object. */ struct user_t { T *pT; @@ -11,7 +11,7 @@ template class Lunar { public: typedef int (T::*mfp)(lua_State *L); - /* Стуктура для склеивания методов объекта Lua с методами объекта C++*/ + /* Structure for gluing Lua object methods with C++ object methods. */ struct Register_t { const char *name; @@ -20,60 +20,56 @@ template class Lunar { static void Register(lua_State *L) { - /* [1] - таблица методов объекта */ + /* [1] - Table of object methods */ lua_newtable(L); int methods = lua_gettop(L); - /* [2] - метатаблица будущих обектов*/ + /* [2] - Metatable for future objects */ luaL_newmetatable(L, T::className); int metatable = lua_gettop(L); - // Размещение таблицы методов в глобальной переменной - // для того, чтобы код lua мог добавлять методы. + // Place the method table in a global variable so that Lua code can add methods. lua_pushvalue(L, methods); lua_setglobal(L, T::className); - // прячем метатаблицу от getmetattable() + // Hide the metatable from getmetattable() lua_pushvalue(L, methods); set(L, metatable, "__metatable"); - // Задаем значение поля __index мета таблицы - // адресом таблицы методов, для того чтобы - // можно было использовать синтекс obj:method() + // Set the `__index` value of the metatable to address the method table, so that we can use + // obj:method() syntax. lua_pushvalue(L, methods); set(L, metatable, "__index"); - // Задаем значение поля __tostring мета таблицы, - // для того, чтобы можно было выводить объект в текстовом виде. + // Set the value of the `__tostring` field of the metatable, so that you can output the object + // in text format. lua_pushcfunction(L, tostring_T); set(L, metatable, "__tostring"); - // Задаем значение поля __gc мета таблицы - // для того, чтобы сборщик мусора мог удалить нанаши объекты + // Set the value of the `__gc` field in the metatable in order for the garbage collector to + // delete the objects. lua_pushcfunction(L, gc_T); set(L, metatable, "__gc"); - // Добавляем новую таблицу для того, чтобы - // сделать её метатаблице таблицы методов. + // Add a new table in order to make it a metatable for the method table. lua_newtable(L); // mt - // Добавление функции сосздания объекта + // Add an object creation function. lua_pushcfunction(L, new_T); - lua_pushvalue(L, -1); // копирование адреса функции для двух случаев. - // задаем метод new у таблицы, для реализации конструктора - // Class:new() - set(L, methods, "new"); // - // Задаем метод __call у мета таблицы для того, чтобы - // можно было использовать метод Class(). + lua_pushvalue(L, -1); // Push a copy of function onto the stack. + // Set the `new` method for the table to implement the constructor: Class:new() + set(L, methods, "new"); + // Set the `__call` method on the metatable so that the table can be used as a function, such + // as invoking a class's constructor `Class()` syntax. set(L, -3, "__call"); // mt.__call = new_T lua_setmetatable(L, methods); - // Заполнение таблицы lua, методами из класса. + // Fill in the Lua table with the methods from the class. for (Register_t *l = T::methods; l->name; ++l) { - // добавление имени метода + // Add the name of the method. lua_pushstring(L, l->name); - // добавление склеивающего параметра. + // Add the glue parameter of type `Register_t *` which wraps the C++ method . lua_pushlightuserdata(L, (void*)l); - // добавление специального склеивателя. + // Push a glue closure `thunk` to execute the method. lua_pushcclosure(L, thunk, 1); lua_settable(L, methods); @@ -82,29 +78,29 @@ template class Lunar { lua_pop(L, 2); } - // Вызов метода из user_t + // Call a method on a `user_t`. static int call(lua_State *L, const char *method, int nargs=0, int nresults=LUA_MULTRET, int errfunc=0) { - // Идекс в стеке для user_t + // Index in the stack for the `user_t`. int base = lua_gettop(L) - nargs; - // Проверка типа user_t + // Check the type of the `user_t`. if (!luaL_checkudata(L, base, T::className)) { - lua_settop(L, base-1); // Удаление всех данных + lua_settop(L, base-1); // Delete all the data off the stack. lua_pushfstring(L, "not a valid %s userdata", T::className); return -1; } - lua_pushstring(L, method); // имя метода - lua_gettable(L, base); // получить method из userdata - if (lua_isnil(L, -1)) { // Метод найден? - lua_settop(L, base-1); // Удаление всех данных + lua_pushstring(L, method); // Method name + lua_gettable(L, base); // Get the method from the userdata. + if (lua_isnil(L, -1)) { // Check if the method cannot be found. + lua_settop(L, base-1); // Delete all the data off the stack. lua_pushfstring(L, "%s missing method '%s'", T::className, method); return -1; } lua_insert(L, base); // put method under userdata, args - int status = lua_pcall(L, 1+nargs, nresults, errfunc); // Вызов метода + int status = lua_pcall(L, 1+nargs, nresults, errfunc); // Method call. if (status) { const char *msg = lua_tostring(L, -1); if (msg == NULL) msg = "(error with no message)"; @@ -113,18 +109,17 @@ template class Lunar { lua_remove(L, base); // remove old message return -1; } - return lua_gettop(L) - base + 1; // кол-во возвращенных результатов + return lua_gettop(L) - base + 1; // Return the number of results from the method call. } - // Добавление в стек пользовательского типа данных, содержащего указатель на - // T *obj + // Push a custom data type onto the stack that contains a pointer to `T *obj`. static int push(lua_State *L, T *obj, bool gc=false) { if (!obj) { lua_pushnil(L); return 0; } - luaL_getmetatable(L, T::className); // поиск мета-таблицы в реестре. + luaL_getmetatable(L, T::className); // Push the metatable matching the class name in the registry. if (lua_isnil(L, -1)) luaL_error(L, "%s missing metatable", T::className); int mt = lua_gettop(L); subtable(L, mt, "userdata", "v"); @@ -132,7 +127,7 @@ template class Lunar { user_t *ud = static_cast(pushuserdata(L, obj, sizeof(user_t))); if (ud) { - ud->pT = obj; // размещение указателя в user_t + ud->pT = obj; // Place the `obj` pointer into the `user_t`. lua_pushvalue(L, mt); lua_setmetatable(L, -2); if (gc == false) { @@ -146,10 +141,10 @@ template class Lunar { } lua_replace(L, mt); lua_settop(L, mt); - return mt; // index userdata содержит указатель на T *obj + return mt; // Return the index to the userdata that contains the pointer to `T *obj`. } - // возврат T* из стека + // Return T* from the stack. static T *check(lua_State *L, int narg) { user_t *ud = static_cast(luaL_checkudata(L, narg, T::className)); @@ -161,27 +156,27 @@ template class Lunar { } private: - Lunar(); // прячем конструктор по умолчанию. + Lunar(); // Hide the default constructor. - // распаковщик функции члена. + // Unpack the method, execute it, and return the result. static int thunk(lua_State *L) { - // стек содержит user_t, следующим прямо за аргументами. + // The stack contains the `user_t` that follows directly behind the arguments. T *obj = check(L, 1); lua_remove(L, 1); - // Получаем связанное с распаковщиком значение registration + // Unpack the `Register_t` value for the method. Register_t *l = static_cast(lua_touserdata(L, lua_upvalueindex(1))); - return (obj->*(l->mfunc))(L); // Вызов метода объекта. + return (obj->*(l->mfunc))(L); // Call the object's method } - // Создание нового объекта и добавление его на вершину стека + // Create a new object and add it to the top of the stack. static int new_T(lua_State *L) { - lua_remove(L, 1); // удаление 'self' - T *obj = new T(L); // Вызов конструктора - push(L, obj, true); // gc_T удалит этот объект когда надо + lua_remove(L, 1); // Remove 'self' + T *obj = new T(L); // Call the constructor + push(L, obj, true); // gc=true, to delete this object when necessary return 1; } - // сборщик мусора + // Garbage collector static int gc_T(lua_State *L) { if (luaL_getmetafield(L, 1, "do not trash")) { lua_pushvalue(L, 1); // dup userdata diff --git a/src/common/mmo.h b/src/common/mmo.h index cb9cbaecfbe..8c9e1772e72 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -1,4 +1,4 @@ -/* +/* =========================================================================== Copyright (c) 2010-2015 Darkstar Dev Teams @@ -35,7 +35,7 @@ #define FFXI_HEADER_SIZE 0x1C // common packet header size #define FFXI_CHANGE_ZONE 0x0A // change zone cmd -// флаги перед именем персонажа +// Flags shown in front of the character's name enum FLAGTYPE : uint32 { @@ -105,8 +105,8 @@ enum MSGSERVTYPE : uint8 typedef std::string string_t; -// для персонажей в size хранится рост, -// для npc и монстров что-то вроде типа используемой модели +// For characters, the size is stored in `size`. +// For NPCs and monsters, something like the type of model is stored. struct look_t { @@ -150,7 +150,7 @@ struct skills_t // index SkillID 0-63 uint16 skill[64]; }; - // ранг используется только в ремеслах. размер 64 необходим для совместимости ID + // The rank is only used in crafts. A size of 64 is required for skill ID compatability. uint8 rank[64]; }; @@ -168,10 +168,15 @@ struct keyitems_t struct position_t { float x; - float y; // высота расположения сущности относительно "уровня моря" + float y; // Entity height, relative to "sea level" float z; - uint16 moving; // что-то вроде расстояния перемещения, необходимое для правильной отрисовки в клиенте количества шагов сущности - uint8 rotation; // угол поворота сущности относительно своей позиции (используется 255 система, место 360°) + uint16 moving; // Somehing like the travel distance, the number of steps required for correct rendering in the client. + + // The angle of rotation of the entity relative to its position. A maximum rotation value of + // 255 is used as the rotation is stored in `uint8`. Use `rotationToRadian()` and + // `radianToRotation()` util functions to convert back and forth between the 255-encoded + // rotation value and the radian value. + uint8 rotation; }; struct stats_t @@ -216,13 +221,13 @@ struct nameflags_t }; }; -// информация для окна поиска +// Information for the search window. struct search_t { - uint8 language; // предпочтительный язык общения - uint8 messagetype; // тип комментария + uint8 language; // Preferred language + uint8 messagetype; // Type of message - string_t message; // комментарий поиска + string_t message; // Search message text }; struct bazaar_t @@ -230,12 +235,13 @@ struct bazaar_t string_t message; }; -// небольшой комментарий к пакетам ниже, определенным в виде констант -// 1-й байт - размер пакета -// через 4-ре байта начинается заголовк 0x49, 0x58, 0x46, 0x46 - IXFF -// после заголовка идет предположительно тип сообщения: -// 0x03 - положительный результат -// 0x04 - ошибка (в случае ошибки начиная с 33 байта идет код ошибки uint16) +// A comment on the packets below, defined as macros. +// byte 0 - packet size +// bytes 4-7 are the packet header "IXFF" (0x49, 0x58, 0x46, 0x46) +// byte 8 - The expected message type: +// 0x03 - positive result +// 0x04 - error (in the case of an error, a uint16 error code is used at byte 32) +// Other #define LOBBY_A1_RESERVEPACKET(a)\ unsigned char a[] = { \ diff --git a/src/common/utils.cpp b/src/common/utils.cpp index 722612b7827..a6ad41ac622 100644 --- a/src/common/utils.cpp +++ b/src/common/utils.cpp @@ -1,4 +1,4 @@ -/* +/* =========================================================================== Copyright (c) 2010-2015 Darkstar Dev Teams @@ -31,13 +31,6 @@ # include #endif -/************************************************************************ -* * -* * -* * -************************************************************************/ - - //-------------------------------------------------- // Return numerical value of a switch configuration // on/off, english, franais, deutsch, espaol @@ -88,12 +81,6 @@ bool bin2hex(char* output, unsigned char* input, size_t count) return true; } -/************************************************************************ -* * -* * -* * -************************************************************************/ - float distance(const position_t& A, const position_t& B) { return sqrt(distanceSquared(A, B)); @@ -108,12 +95,6 @@ float distanceSquared(const position_t& A, const position_t& B) return diff_x * diff_x + diff_y * diff_y + diff_z * diff_z; } -/************************************************************************ -* * -* * -* * -************************************************************************/ - int32 intpow32(int32 base, int32 exponent) { int32 power = 1; @@ -127,12 +108,6 @@ int32 intpow32(int32 base, int32 exponent) return power; } -/************************************************************************ -* * -* * -* * -************************************************************************/ - void getMSB(uint32* result, uint32 value) { *result = 0; @@ -162,13 +137,6 @@ uint8 radianToRotation(float radian) return (uint8)((radian / (2 * M_PI)) * 256); } - -/************************************************************************ -* * -* * -* * -************************************************************************/ - uint8 getangle(const position_t& A, const position_t& B) { uint8 angle = (uint8)(atanf((B.z - A.z) / (B.x - A.x)) * -(128.0f / M_PI)); @@ -177,9 +145,9 @@ uint8 getangle(const position_t& A, const position_t& B) } /************************************************************************ -* * -* Проверяем, находится ли цель в поле зрения (coneAngle) * -* * +* * +* Check whether the target is in the field of view (coneAngle) * +* * ************************************************************************/ bool isFaceing(const position_t& A, const position_t& B, uint8 coneAngle) @@ -212,9 +180,9 @@ position_t nearPosition(const position_t& A, float offset, float radian) } /************************************************************************ -* * -* Методы для работы с битовыми массивами * -* * +* * +* Methods for working with bit arrays. * +* * ************************************************************************/ int32 hasBit(uint16 value, uint8* BitArray, uint32 size) @@ -247,12 +215,6 @@ int32 delBit(uint16 value, uint8* BitArray, uint32 size) return 0; } -/************************************************************************ -* * -* * -* * -************************************************************************/ - uint32 packBitsBE(uint8* target, uint64 value, int32 bitOffset, uint8 lengthInBit) { return packBitsBE(target, value, 0, bitOffset, lengthInBit); diff --git a/src/common/utils.h b/src/common/utils.h index c5af060d8cc..a4af5a387af 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -1,4 +1,4 @@ -/* +/* =========================================================================== Copyright (c) 2010-2015 Darkstar Dev Teams @@ -45,13 +45,13 @@ int32 intpow32(int32 base, int32 exponent); // Exponential power of integer void getMSB(uint32* result,uint32 value); // fast Most Significant Byte search under GCC or MSVC. Fallback included. float rotationToRadian(uint8 rotation); uint8 radianToRotation(float radian); -uint8 getangle(const position_t& A, const position_t& B); // А - основная сущность, B - цель сущности (проекция вектора на OX) -bool isFaceing(const position_t& A, const position_t& B, uint8 coneAngle); // А - основная сущность, B - цель сущности +uint8 getangle(const position_t& A, const position_t& B); // А - the main entity, B - target entity (vector projection onto the X-axis) +bool isFaceing(const position_t& A, const position_t& B, uint8 coneAngle); // А - the main entity, B - the target entity position_t nearPosition(const position_t& A, float offset, float radian); // Returns a position near the given position -int32 hasBit(uint16 value, uint8* BitArray, uint32 size); // проверяем наличие бита в массиве -int32 addBit(uint16 value, uint8* BitArray, uint32 size); // добавляем бит в массив -int32 delBit(uint16 value, uint8* BitArray, uint32 size); // удаляем бит из массива +int32 hasBit(uint16 value, uint8* BitArray, uint32 size); // Check for the presence of a bit in the array +int32 addBit(uint16 value, uint8* BitArray, uint32 size); // Adds a bit to the array +int32 delBit(uint16 value, uint8* BitArray, uint32 size); // Deletes a bit from the array //(un)pack functions for Big Endian(BE) targets uint32 packBitsBE(uint8* target, uint64 value, int32 byteOffset, int32 bitOffset, uint8 lengthInBit); diff --git a/src/login/lobby.cpp b/src/login/lobby.cpp index 6ab18c03035..2b9d0b20ebf 100644 --- a/src/login/lobby.cpp +++ b/src/login/lobby.cpp @@ -1,4 +1,4 @@ -/* +/* =========================================================================== Copyright (c) 2010-2015 Darkstar Dev Teams @@ -35,12 +35,6 @@ int32 login_lobbydata_fd; int32 login_lobbyview_fd; -/************************************************************************ -* * -* * -* * -************************************************************************/ - int32 connect_client_lobbydata(int32 listenfd) { int32 fd = 0; @@ -56,12 +50,6 @@ int32 connect_client_lobbydata(int32 listenfd) return -1; } -/************************************************************************ -* * -* * -* * -************************************************************************/ - int32 lobbydata_parse(int32 fd) { login_session_data_t* sd = (login_session_data_t*)session[fd]->session_data; @@ -125,7 +113,7 @@ int32 lobbydata_parse(int32 fd) unsigned char CharList[2500]; memset(CharList, 0, sizeof(CharList)); - //запись зарезервированных чисел + // Store the reserved numbers. CharList[0] = 0xE0; CharList[1] = 0x08; CharList[4] = 0x49; CharList[5] = 0x58; CharList[6] = 0x46; CharList[7] = 0x46; CharList[8] = 0x20; @@ -176,8 +164,8 @@ int32 lobbydata_parse(int32 fd) uList[0] = 0x03; int i = 0; - //Считывание информации о конкректном персонаже - //Загрузка всей необходимой информации о персонаже из базы + // Read information about a specific character. + // Extract all the necessary information about the character from the database. while (Sql_NextRow(SqlHandle) != SQL_NO_DATA) { char* strCharName = nullptr; @@ -336,7 +324,7 @@ int32 lobbydata_parse(int32 fd) memcpy(MainReservePacket, ReservePacket, ref(ReservePacket, 0)); - // необходиму одалять сессию, необработанную игровым сервером + // If the session was not processed by the game server, then it must be deleted. Sql_Query(SqlHandle, "DELETE FROM accounts_sessions WHERE accid = %u and client_port = 0", sd->accid); char session_key[sizeof(key3) * 2 + 1]; @@ -346,10 +334,10 @@ int32 lobbydata_parse(int32 fd) if (Sql_Query(SqlHandle, fmtQuery, sd->accid, charid, session_key, ZoneIP, ZonePort, sd->client_addr, (uint8)session[sd->login_lobbyview_fd]->ver_mismatch) == SQL_ERROR) { - //отправляем клиенту сообщение об ошибке + // Send error message to the client. LOBBBY_ERROR_MESSAGE(ReservePacket); - // устанавливаем код ошибки - // Unable to connect to world server. Specified operation failed + // Set the error code: + // Unable to connect to world server. Specified operation failed ref(ReservePacket, 32) = 305; memcpy(MainReservePacket, ReservePacket, ref(ReservePacket, 0)); } @@ -368,8 +356,8 @@ int32 lobbydata_parse(int32 fd) { //either there is no character for this charid/accid, or there is no zone for this char's zone LOBBBY_ERROR_MESSAGE(ReservePacket); - // устанавливаем код ошибки - // Unable to connect to world server. Specified operation failed + // Set the error code: + // Unable to connect to world server. Specified operation failed ref(ReservePacket, 32) = 305; memcpy(MainReservePacket, ReservePacket, ref(ReservePacket, 0)); } @@ -388,7 +376,7 @@ int32 lobbydata_parse(int32 fd) if (SendBuffSize == 0x24) { - // выходим в случае ошибки без разрыва соединения + // In the event of an error, exit without breaking the connection. return -1; } @@ -426,12 +414,6 @@ int32 lobbydata_parse(int32 fd) return 0; }; -/************************************************************************ -* * -* * -* * -************************************************************************/ - int32 do_close_lobbydata(login_session_data_t *loginsd, int32 fd) { if (loginsd != nullptr) @@ -455,12 +437,6 @@ int32 do_close_lobbydata(login_session_data_t *loginsd, int32 fd) return -1; } -/************************************************************************ -* * -* * -* * -************************************************************************/ - int32 connect_client_lobbyview(int32 listenfd) { int32 fd = 0; @@ -474,12 +450,6 @@ int32 connect_client_lobbyview(int32 listenfd) return -1; } -/************************************************************************ -* * -* * -* * -************************************************************************/ - int32 lobbyview_parse(int32 fd) { login_session_data_t* sd = (login_session_data_t*)session[fd]->session_data; @@ -580,11 +550,11 @@ int32 lobbyview_parse(int32 fd) } } - //Хеширование пакета, и запись значения Хеш функции в пакет + // Hash the packet data and then write the value of the hash into the packet. unsigned char Hash[16]; md5(MainReservePacket, Hash, sendsize); memcpy(MainReservePacket + 12, Hash, 16); - //Запись итогового пакета + // Finalize the packet. session[fd]->wdata.assign((const char*)MainReservePacket, sendsize); session[fd]->ver_mismatch = ver_mismatch; RFIFOSKIP(fd, session[fd]->rdata.size()); @@ -610,8 +580,8 @@ int32 lobbyview_parse(int32 fd) RFIFOSKIP(fd, session[fd]->rdata.size()); RFIFOFLUSH(fd); - //Выполнение удаления персонажа из основных таблиц - //Достаточно удалить значение из таблицы chars, все остальное сделает mysql-сервер + // Perform character deletion from the database. It is sufficient to remove the + // value from the `chars` table. The mysql server will handle the rest. const char *pfmtQuery = "DELETE FROM chars WHERE charid = %i AND accid = %i"; Sql_Query(SqlHandle, pfmtQuery, CharID, sd->accid); @@ -785,12 +755,6 @@ int32 lobbyview_parse(int32 fd) return 0; }; -/************************************************************************ -* * -* * -* * -************************************************************************/ - int32 do_close_lobbyview(login_session_data_t* sd, int32 fd) { ShowInfo(CL_WHITE"lobbyview_parse" CL_RESET": " CL_WHITE"%s" CL_RESET" shutdown the socket\n", sd->login); @@ -798,15 +762,9 @@ int32 do_close_lobbyview(login_session_data_t* sd, int32 fd) return 0; } -/************************************************************************ -* * -* * -* * -************************************************************************/ - int32 lobby_createchar(login_session_data_t *loginsd, int8 *buf) { - // инициализируем генератор случайных чисел + // Seed the random number generator. srand(clock()); char_mini createchar; @@ -873,12 +831,6 @@ int32 lobby_createchar(login_session_data_t *loginsd, int8 *buf) return 0; }; -/************************************************************************ -* * -* * -* * -************************************************************************/ - int32 lobby_createchar_save(uint32 accid, uint32 charid, char_mini* createchar) { const char* Query = "INSERT INTO chars(charid,accid,charname,pos_zone,nation) VALUES(%u,%u,'%s',%u,%u);"; @@ -907,9 +859,6 @@ int32 lobby_createchar_save(uint32 accid, uint32 charid, char_mini* createchar) return -1; } - - - // people reported char creation errors, here is a fix. Query = "INSERT INTO char_exp(charid) VALUES(%u) \ @@ -936,8 +885,6 @@ int32 lobby_createchar_save(uint32 accid, uint32 charid, char_mini* createchar) ON DUPLICATE KEY UPDATE charid = charid;"; if (Sql_Query(SqlHandle, Query, charid, createchar->m_mjob) == SQL_ERROR) return -1; - - //hot fix Query = "DELETE FROM char_inventory WHERE charid = %u"; if (Sql_Query(SqlHandle, Query, charid) == SQL_ERROR) return -1; @@ -945,8 +892,5 @@ int32 lobby_createchar_save(uint32 accid, uint32 charid, char_mini* createchar) Query = "INSERT INTO char_inventory(charid) VALUES(%u);"; if (Sql_Query(SqlHandle, Query, charid, createchar->m_mjob) == SQL_ERROR) return -1; - - - return 0; } diff --git a/src/search/data_loader.cpp b/src/search/data_loader.cpp index 32221ab31d1..fef223ae3d6 100644 --- a/src/search/data_loader.cpp +++ b/src/search/data_loader.cpp @@ -1,4 +1,4 @@ -/* +/* =========================================================================== Copyright (c) 2010-2015 Darkstar Dev Teams @@ -51,7 +51,7 @@ CDataLoader::~CDataLoader() /************************************************************************ * * -* История продаж предмета * +* Returns the auction house sale history for a given item. * * * ************************************************************************/ @@ -88,8 +88,8 @@ std::vector CDataLoader::GetAHItemHystory(uint16 ItemID, bool stack) /************************************************************************ * * -* Список продаваемых предметов в указанной категории * * The list of items sold in this category * +* * ************************************************************************/ std::vector CDataLoader::GetAHItemsToCategory(uint8 AHCategoryID, int8* OrderByString) @@ -133,7 +133,7 @@ std::vector CDataLoader::GetAHItemsToCategory(uint8 AHCategoryID, int8* /************************************************************************ * * -* Количество активных игроков в мире * +* Returns the number of active players in the world. * * * ************************************************************************/ @@ -164,7 +164,8 @@ uint32 CDataLoader::GetPlayersCount(search_req sr) /************************************************************************ * * -* Список найденных персонажей в игровом мире * +* Returns the list of characters found in the world that match the * +* search request. * * Job ID is 0 for none specified. * ************************************************************************/ @@ -334,7 +335,7 @@ std::list CDataLoader::GetPlayersList(search_req sr, int* count) /************************************************************************ * * -* Список персонажей, состоящих в одной группе * +* Returns the list of characters in a given party/alliance group. * * * ************************************************************************/ @@ -393,7 +394,7 @@ std::list CDataLoader::GetPartyList(uint16 PartyID, uint16 Allian /************************************************************************ * * -* Список персонажей, состоящих в одной linkshell * +* Returns the list of characters in a given linkshell. * * * ************************************************************************/ @@ -456,6 +457,7 @@ std::list CDataLoader::GetLinkshellList(uint32 LinkshellID) return LinkshellList; } + void CDataLoader::ExpireAHItems() { Sql_t* sqlH2 = Sql_Malloc(); diff --git a/src/search/packets/auction_history.cpp b/src/search/packets/auction_history.cpp index 8657ec27952..6837da3f247 100644 --- a/src/search/packets/auction_history.cpp +++ b/src/search/packets/auction_history.cpp @@ -1,4 +1,4 @@ -/* +/* =========================================================================== Copyright (c) 2010-2015 Darkstar Dev Teams @@ -28,12 +28,6 @@ along with this program. If not, see http://www.gnu.org/licenses/ #include "auction_history.h" -/************************************************************************ -* * -* * -* * -************************************************************************/ - CAHHistoryPacket::CAHHistoryPacket(uint16 ItemID) { m_count = 0; @@ -41,16 +35,10 @@ CAHHistoryPacket::CAHHistoryPacket(uint16 ItemID) memset(m_PData, 0, sizeof(m_PData)); ref(m_PData, (0x0A)) = 0x80; - ref(m_PData, (0x0B)) = 0x85; // packe type + ref(m_PData, (0x0B)) = 0x85; // packet type ref(m_PData, 0x10) = ItemID; } -/************************************************************************ -* * -* * -* * -************************************************************************/ - void CAHHistoryPacket::AddItem(ahHistory* item) { if (m_count < 10) @@ -68,7 +56,7 @@ void CAHHistoryPacket::AddItem(ahHistory* item) /************************************************************************ * * -* Возвращаем собранный пакет * +* Returns the packet's data. * * * ************************************************************************/ @@ -79,7 +67,7 @@ uint8* CAHHistoryPacket::GetData() /************************************************************************ * * -* Возвращаем размер отправляемого пакета * +* Returns the size of the packet. * * * ************************************************************************/ diff --git a/src/search/packets/auction_list.cpp b/src/search/packets/auction_list.cpp index 8c41a5189d3..ddfa5c78406 100644 --- a/src/search/packets/auction_list.cpp +++ b/src/search/packets/auction_list.cpp @@ -1,4 +1,4 @@ -/* +/* =========================================================================== Copyright (c) 2010-2015 Darkstar Dev Teams @@ -30,8 +30,10 @@ along with this program. If not, see http://www.gnu.org/licenses/ /************************************************************************ * * -* Если количество отправляемых предметов превышает 20, то отправляем * -* их несколькими пакетами, в каждый их коротых записываем смещение * +* If the number of items exceeds 20, then we send several packets. * +* The `offset` is used to denote which set of items this packet * +* contains, relative to the total number of items across all * +* packets in the list. * * * ************************************************************************/ @@ -47,7 +49,7 @@ CAHItemsListPacket::CAHItemsListPacket(uint16 offset) /************************************************************************ * * -* Добавляем предмет в пакет (по 10 байт на предмер) * +* Add an item to the packet (10 bytes per item). * * * ************************************************************************/ @@ -63,7 +65,7 @@ void CAHItemsListPacket::AddItem(ahItem* item) /************************************************************************ * * -* Устанавливаем общее количество отправляемых предметов * +* Set the total number of items sent in the packet. * * * ************************************************************************/ @@ -84,7 +86,7 @@ void CAHItemsListPacket::SetItemCount(uint16 count) /************************************************************************ * * -* Возвращаем собранный пакет * +* Return the data for the packet. * * * ************************************************************************/ @@ -95,7 +97,7 @@ uint8* CAHItemsListPacket::GetData() /************************************************************************ * * -* Возвращаем размер отправляемого пакета * +* Return the total size of the packet. * * * ************************************************************************/ diff --git a/src/search/packets/linkshell_list.cpp b/src/search/packets/linkshell_list.cpp index b2fd80aa581..d4e872b8514 100644 --- a/src/search/packets/linkshell_list.cpp +++ b/src/search/packets/linkshell_list.cpp @@ -1,4 +1,4 @@ -/* +/* =========================================================================== Copyright (c) 2010-2015 Darkstar Dev Teams @@ -31,13 +31,6 @@ along with this program. If not, see http://www.gnu.org/licenses/ #include "linkshell_list.h" - -/************************************************************************ -* * -* * -* * -************************************************************************/ - CLinkshellListPacket::CLinkshellListPacket(uint32 linkshellid, uint32 Total) { m_linkshellid = linkshellid; @@ -48,7 +41,7 @@ CLinkshellListPacket::CLinkshellListPacket(uint32 linkshellid, uint32 Total) ref(m_data, (0x0A)) = 0x80; ref(m_data, (0x0B)) = 0x82; // packet type - // ref(m_data,(0x0E)) = 0x00; // количество персонажей в пакете + // ref(m_data,(0x0E)) = 0x00; // Number of characters per packet ref(m_data, (0x0E)) = Total; } @@ -59,7 +52,7 @@ CLinkshellListPacket::~CLinkshellListPacket() /************************************************************************ * * -* Добавляем персонажа в пакет * +* Add the player to the packet. * * * ************************************************************************/ @@ -130,16 +123,16 @@ void CLinkshellListPacket::AddPlayer(SearchEntity* PPlayer) m_offset = packBitsLE(m_data, SEARCH_LANGUAGE, m_offset, 5); m_offset = packBitsLE(m_data, PPlayer->languages, m_offset, 16); - if (m_offset % 8 > 0) m_offset += 8 - m_offset % 8; // побайтное выравнивание данных + if (m_offset % 8 > 0) m_offset += 8 - m_offset % 8; // Byte alignment - ref(m_data, size_offset) = m_offset / 8 - size_offset - 1; // размер данных сущности - ref(m_data, (0x08)) = m_offset / 8; // размер отправляемых данных + ref(m_data, size_offset) = m_offset / 8 - size_offset - 1; // Entity data size + ref(m_data, (0x08)) = m_offset / 8; // Size of the data to send delete PPlayer; } /************************************************************************ * * -* Возвращаем собранный пакет +* Returns the packet's data. * * * ************************************************************************/ @@ -150,7 +143,7 @@ uint8* CLinkshellListPacket::GetData() /************************************************************************ * * -* Возвращаем размер отправляемого пакета * +* Returns the size of the packet. * * * ************************************************************************/ diff --git a/src/search/packets/party_list.cpp b/src/search/packets/party_list.cpp index 5956c87bc0c..3f80e99d35d 100644 --- a/src/search/packets/party_list.cpp +++ b/src/search/packets/party_list.cpp @@ -1,4 +1,4 @@ -/* +/* =========================================================================== Copyright (c) 2010-2015 Darkstar Dev Teams @@ -31,13 +31,6 @@ along with this program. If not, see http://www.gnu.org/licenses/ #include "party_list.h" - -/************************************************************************ -* * -* * -* * -************************************************************************/ - CPartyListPacket::CPartyListPacket(uint32 partyid, uint32 Total) { m_partyid = partyid; @@ -48,7 +41,7 @@ CPartyListPacket::CPartyListPacket(uint32 partyid, uint32 Total) ref(m_data, (0x0A)) = 0x80; ref(m_data, (0x0B)) = 0x82; // packet type - // ref(m_data,(0x0E)) = 0x00; // количество персонажей в пакете + // ref(m_data,(0x0E)) = 0x00; // Number of characters per packet. ref(m_data, (0x0E)) = Total; } @@ -59,7 +52,7 @@ CPartyListPacket::~CPartyListPacket() /************************************************************************ * * -* Добавляем персонажа в пакет * +* Add the player to the packet. * * * ************************************************************************/ @@ -126,16 +119,16 @@ void CPartyListPacket::AddPlayer(SearchEntity* PPlayer) m_offset = packBitsLE(m_data, SEARCH_LANGUAGE, m_offset, 5); m_offset = packBitsLE(m_data, PPlayer->languages, m_offset, 16); - if (m_offset % 8 > 0) m_offset += 8 - m_offset % 8; // побайтное выравнивание данных + if (m_offset % 8 > 0) m_offset += 8 - m_offset % 8; // Byte alignment - ref(m_data, size_offset) = m_offset / 8 - size_offset - 1; // размер данных сущности - ref(m_data, (0x08)) = m_offset / 8; // размер отправляемых данных + ref(m_data, size_offset) = m_offset / 8 - size_offset - 1; // Entity data size + ref(m_data, (0x08)) = m_offset / 8; // Size of the data to send delete PPlayer; } /************************************************************************ * * -* Возвращаем собранный пакет +* Returns the packet's data. * * * ************************************************************************/ @@ -162,7 +155,7 @@ uint8* CPartyListPacket::GetData() /************************************************************************ * * -* Возвращаем размер отправляемого пакета * +* Returns the size of the packet. * * * ************************************************************************/ diff --git a/src/search/packets/search_list.cpp b/src/search/packets/search_list.cpp index c7deca51a7c..05d2af4909b 100644 --- a/src/search/packets/search_list.cpp +++ b/src/search/packets/search_list.cpp @@ -1,4 +1,4 @@ -/* +/* =========================================================================== Copyright (c) 2010-2015 Darkstar Dev Teams @@ -29,13 +29,6 @@ along with this program. If not, see http://www.gnu.org/licenses/ #include "search_list.h" - -/************************************************************************ -* * -* * -* * -************************************************************************/ - CSearchListPacket::CSearchListPacket(uint32 Total) { m_count = 0; @@ -46,16 +39,10 @@ CSearchListPacket::CSearchListPacket(uint32 Total) ref(m_data, (0x0A)) = 0x80; ref(m_data, (0x0B)) = 0x80; - ref(m_data, (0x0E)) = Total; // общее количество найденных персонажей (может отличаться от отправляемого) + ref(m_data, (0x0E)) = Total; // The total number of character found (may differ from the amount that gets sent) } -/************************************************************************ -* * -* * -* * -************************************************************************/ - -// в один пакет мождет быть добавлено не более 20-ти персонажей +// A maximum of 20 characters can be added to a single packet. void CSearchListPacket::AddPlayer(SearchEntity* PPlayer) { @@ -119,16 +106,16 @@ void CSearchListPacket::AddPlayer(SearchEntity* PPlayer) m_offset = packBitsLE(m_data, SEARCH_LANGUAGE, m_offset, 5); m_offset = packBitsLE(m_data, PPlayer->languages, m_offset, 16); - if (m_offset % 8 > 0) m_offset += 8 - m_offset % 8; // побайтное выравнивание данных + if (m_offset % 8 > 0) m_offset += 8 - m_offset % 8; // Byte alignment - ref(m_data, size_offset) = m_offset / 8 - size_offset - 1; // размер данных сущности - ref(m_data, (0x08)) = m_offset / 8; // размер отправляемых данных + ref(m_data, size_offset) = m_offset / 8 - size_offset - 1; // Entity data size + ref(m_data, (0x08)) = m_offset / 8; // Size of the data to send delete PPlayer; } /************************************************************************ * * -* Возвращаем собранный пакет * +* Returns the packet's data. * * * ************************************************************************/ @@ -139,7 +126,7 @@ uint8* CSearchListPacket::GetData() /************************************************************************ * * -* Возвращаем размер отправляемого пакета * +* Returns the size of the packet. * * * ************************************************************************/ diff --git a/src/search/search.cpp b/src/search/search.cpp index fa5560e3a99..e865ed1ab15 100644 --- a/src/search/search.cpp +++ b/src/search/search.cpp @@ -1,4 +1,4 @@ -/* +/* =========================================================================== Copyright (c) 2010-2015 Darkstar Dev Teams @@ -104,7 +104,7 @@ void login_config_read(const int8* file); // We only need the search serve /************************************************************************ * * -* Отображения содержимого входящего пакета в консоли * +* Prints the contents of the packet in `data` to the console. * * * ************************************************************************/ @@ -136,12 +136,6 @@ void PrintPacket(char* data, int size) printf("\n"); } -/************************************************************************ -* * -* * -* * -************************************************************************/ - int32 main(int32 argc, char **argv) { #ifdef WIN32 @@ -282,7 +276,7 @@ int32 main(int32 argc, char **argv) std::thread(TCPComm, ClientSocket).detach(); } - // TODO: сейчас мы никогда сюда не попадем + // TODO: The code below this line will never be reached. // shutdown the connection since we're done #ifdef WIN32 @@ -457,12 +451,6 @@ void login_config_read(const int8* file) fclose(fp); } -/************************************************************************ -* * -* * -* * -************************************************************************/ - void TCPComm(SOCKET socket) { //ShowMessage("TCP connection from client with port: %u\n", htons(CommInfo.port)); @@ -514,7 +502,7 @@ void TCPComm(SOCKET socket) /************************************************************************ * * -* Запрос списка персонажей (party/linkshell) * +* Character list request (party/linkshell) * * * ************************************************************************/ @@ -563,12 +551,6 @@ void HandleGroupListRequest(CTCPRequestPacket& PTCPRequest) } } -/************************************************************************ -* * -* * -* * -************************************************************************/ - void HandleSearchComment(CTCPRequestPacket& PTCPRequest) { uint8 packet[] = @@ -590,12 +572,6 @@ void HandleSearchComment(CTCPRequestPacket& PTCPRequest) PTCPRequest.SendRawToSocket(packet, sizeof(packet)); } -/************************************************************************ -* * -* * -* * -************************************************************************/ - void HandleSearchRequest(CTCPRequestPacket& PTCPRequest) { search_req sr = _HandleSearchRequest(PTCPRequest); @@ -615,27 +591,19 @@ void HandleSearchRequest(CTCPRequestPacket& PTCPRequest) PTCPRequest.SendToSocket(PSearchPacket.GetData(), PSearchPacket.GetSize()); } -/************************************************************************ -* * - - -* * -* * -************************************************************************/ - void HandleAuctionHouseRequest(CTCPRequestPacket& PTCPRequest) { uint8* data = (uint8*)PTCPRequest.GetData(); uint8 AHCatID = ref(data, 0x16); - //2 - уровень -- level - //3 - раса -- race - //4 - профессия -- job - //5 - урон -- damage - //6 - задержка -- delay - //7 - защита -- defense - //8 - сопротивление -- resistance - //9 - название -- name + //2 - level + //3 - race + //4 - job + //5 - damage + //6 - delay + //7 - defense + //8 - resistance + //9 - name string_t OrderByString = "ORDER BY"; uint8 paramCount = ref(data, 0x12); for (uint8 i = 0; i < paramCount; ++i) // параметры сортировки предметов @@ -677,12 +645,6 @@ void HandleAuctionHouseRequest(CTCPRequestPacket& PTCPRequest) } } -/************************************************************************ -* * -* * -* * -************************************************************************/ - void HandleAuctionHouseHistory(CTCPRequestPacket& PTCPRequest) { uint8* data = (uint8*)PTCPRequest.GetData(); @@ -702,16 +664,10 @@ void HandleAuctionHouseHistory(CTCPRequestPacket& PTCPRequest) PTCPRequest.SendToSocket(PAHPacket.GetData(), PAHPacket.GetSize()); } -/************************************************************************ -* * -* * -* * -************************************************************************/ - search_req _HandleSearchRequest(CTCPRequestPacket& PTCPRequest) { - // суть в том, чтобы заполнить некоторую структуру, на основании которой будет создан запрос к базе - // результат поиска в базе отправляется клиенту + // This function constructs a `search_req` based on which query should be send to the database. + // The results from the database will eventually be sent to the client. uint32 bitOffset = 0; @@ -971,8 +927,10 @@ search_req _HandleSearchRequest(CTCPRequestPacket& PTCPRequest) } return sr; - // не обрабатываем последние биты, что мешает в одну кучу например "/blacklist delete Name" и "/sea all Name" + // не обрабатываем последние биты, что мешает в одну кучу + // For example: "/blacklist delete Name" and "/sea all Name" } + /************************************************************************ * * * Task Manager Thread * diff --git a/src/search/tcp_request.cpp b/src/search/tcp_request.cpp index 087f61d3ccb..9bbe317dfc8 100644 --- a/src/search/tcp_request.cpp +++ b/src/search/tcp_request.cpp @@ -1,4 +1,4 @@ -/* +/* =========================================================================== Copyright (c) 2010-2015 Darkstar Dev Teams @@ -48,12 +48,6 @@ typedef u_int SOCKET; #define DEFAULT_BUFLEN 1024 -/************************************************************************ -* * -* * -* * -************************************************************************/ - CTCPRequestPacket::CTCPRequestPacket(SOCKET* socket) : m_data(nullptr), m_size(0), m_socket(socket), blowfish(blowfish_t()) { uint8 keys[24] = @@ -82,34 +76,16 @@ CTCPRequestPacket::~CTCPRequestPacket() #endif } -/************************************************************************ -* * -* * -* * -************************************************************************/ - uint8* CTCPRequestPacket::GetData() { return m_data; } -/************************************************************************ -* * -* * -* * -************************************************************************/ - int32 CTCPRequestPacket::GetSize() { return m_size; } -/************************************************************************ -* * -* * -* * -************************************************************************/ - int32 CTCPRequestPacket::ReceiveFromSocket() { char recvbuf[DEFAULT_BUFLEN]; @@ -145,7 +121,9 @@ int32 CTCPRequestPacket::ReceiveFromSocket() /************************************************************************ * * -* Отправляем данные без шифрования * +* Sends raw data to the socket. * +* * +* NOTE: The data is sent without encryption. * * * ************************************************************************/ @@ -166,12 +144,6 @@ int32 CTCPRequestPacket::SendRawToSocket(uint8* data, uint32 length) return 1; } -/************************************************************************ -* * -* * -* * -************************************************************************/ - int32 CTCPRequestPacket::SendToSocket(uint8* data, uint32 length) { int32 iResult; @@ -208,12 +180,6 @@ int32 CTCPRequestPacket::SendToSocket(uint8* data, uint32 length) return ReceiveFromSocket(); } -/************************************************************************ -* * -* * -* * -************************************************************************/ - int32 CTCPRequestPacket::CheckPacketHash() { uint8 PacketHash[16]; @@ -237,12 +203,6 @@ int32 CTCPRequestPacket::CheckPacketHash() return 1; } -/************************************************************************ -* * -* * -* * -************************************************************************/ - uint8 CTCPRequestPacket::GetPacketType() { TPZ_DEBUG_BREAK_IF(m_data == nullptr) @@ -250,12 +210,6 @@ uint8 CTCPRequestPacket::GetPacketType() return m_data[0x0B]; } -/************************************************************************ -* * -* * -* * -************************************************************************/ - int32 CTCPRequestPacket::decipher() { md5((uint8*)(key), blowfish.hash, 20);