Skip to content
This repository has been archived by the owner on Dec 4, 2020. It is now read-only.

Commit

Permalink
Update russian comments to english for the following dirs: (#427)
Browse files Browse the repository at this point in the history
- documentation/*
- src/common/*
- src/login/*
- src/search/*

The only directories that still need translations are:

- src/map/*
  • Loading branch information
mrhappyasthma authored Mar 20, 2020
1 parent c52431e commit 820f822
Show file tree
Hide file tree
Showing 14 changed files with 171 additions and 389 deletions.
4 changes: 1 addition & 3 deletions documentation/ZoneIDs.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@

Список известных зон
List of known zones
List of known zones

0 - 00 - Tech Demo Area
1 - 01 - Phanauet Channel
Expand Down
105 changes: 50 additions & 55 deletions src/common/lua/lunar.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#pragma once
#pragma once
#include "lua.hpp"
/*Связыватель объектов C++ с объектами Lua*/
/* Binds C++ objects to Lua objects. */
template <typename T> class Lunar {

/*Структура инкапсулирования объекта C++ в объект Lua*/
/* Structure for encapsulating a C++ object in a Lua object. */
struct user_t
{
T *pT;
};
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;
Expand All @@ -20,60 +20,56 @@ template <typename T> 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);
Expand All @@ -82,29 +78,29 @@ template <typename T> 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)";
Expand All @@ -113,26 +109,25 @@ template <typename T> 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");

user_t *ud =
static_cast<user_t*>(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) {
Expand All @@ -146,10 +141,10 @@ template <typename T> 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<user_t*>(luaL_checkudata(L, narg, T::className));
Expand All @@ -161,27 +156,27 @@ template <typename T> 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<Register_t*>(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
Expand Down
42 changes: 24 additions & 18 deletions src/common/mmo.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
===========================================================================
Copyright (c) 2010-2015 Darkstar Dev Teams
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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];
};

Expand All @@ -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
Expand Down Expand Up @@ -216,26 +221,27 @@ 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
{
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[] = { \
Expand Down
Loading

0 comments on commit 820f822

Please sign in to comment.