Commit 6a05d581 authored by mercury233's avatar mercury233 Committed by GitHub

Merge branch 'master' into rename_deck_fh

parents c8d39796 b565e865
project (ygo)
cmake_minimum_required (VERSION 2.8)
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "Setting build type to 'Debug' as none was specified.")
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/macros")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
include (AutoFiles)
include (platform/settings)
if (MSVC)
add_subdirectory (event)
add_subdirectory (freetype)
add_subdirectory (irrlicht)
add_subdirectory (sqlite3)
else ()
find_package(LibEvent REQUIRED)
find_package(Freetype REQUIRED)
find_package(Irrlicht REQUIRED)
find_package(Sqlite REQUIRED)
find_package(OpenGL REQUIRED)
endif ()
option(USE_IRRKLANG "Use irrKlang sound library" OFF)
if (USE_IRRKLANG)
set(IRRKLANG_DIR ${CMAKE_SOURCE_DIR}/irrKlang)
endif ()
add_subdirectory (lua)
add_subdirectory (ocgcore)
add_subdirectory (gframe)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
add_definitions ( "-fexceptions" "-fomit-frame-pointer" "-fno-strict-aliasing" "-Wno-format-security" )
add_definitions ( "-static-libgcc" "-static-libstdc++" )
add_definitions ( "-wd4996" "-D_CRT_SECURE_NO_WARNINGS" "-D_ITERATOR_DEBUG_LEVEL=0" )
add_definitions ( "-D_UNICODE" "-DUNICODE" "/utf-8" )
include (MSVCMultipleProcessCompile)
include (MSVCStaticRuntime)
function (AutoFiles _folder _base _pattern)
if (ARGC GREATER 3)
set(_exclude ${ARGN})
else ()
set(_exclude)
endif ()
file (GLOB _files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/ ${_folder}/*)
set (folderFiles)
foreach (_fname ${_files})
if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${_fname})
AutoFiles ("${_fname}" "${_base}" "${_pattern}" "${_exclude}")
elseif (_fname MATCHES ${_pattern})
if(_exclude)
if (NOT _fname MATCHES ${_exclude})
set(folderFiles ${folderFiles} ${_fname})
endif ()
else ()
set(folderFiles ${folderFiles} ${_fname})
endif ()
endif ()
endforeach ()
string(REPLACE "./" "" _folder2 ${_folder})
string(REPLACE "/" "\\" _folder2 ${_folder2})
if (_folder2 STREQUAL ".")
source_group(${_base} FILES ${folderFiles})
else ()
source_group(${_base}\\${_folder2} FILES ${folderFiles})
endif ()
set(AUTO_FILES_RESULT ${AUTO_FILES_RESULT} ${folderFiles} PARENT_SCOPE)
endfunction ()
# - Try to find the dl library
# Once done this will define
#
# DL_FOUND - System has libdl
# DL_LIBRARIES - The libraries needed to use libdl
# DL_DEFINITIONS - Compiler switches required for using libdl
FIND_PATH(DL_INCLUDE_DIR dlfcn.h
PATH_SUFFIXES include
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
FIND_LIBRARY(DL_LIBRARIES NAMES dl
PATH_SUFFIXES lib64 lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(libdl DEFAULT_MSG DL_LIBRARIES DL_INCLUDE_DIR)
MARK_AS_ADVANCED(DL_INCLUDE_DIR DL_LIBRARIES)
# - Try to find the Lib library
# Once done this will define
#
# FREETYPE_FOUND - System has freetype
# FREETYPE_INCLUDE_DIR - The freetype include directory
# FREETYPE_LIBRARIES - The libraries needed to use freetype
# FREETYPE_DEFINITIONS - Compiler switches required for using freetype
SET(FREETYPE_DEFINITIONS ${PC_FREETYPE_CFLAGS_OTHER})
FIND_PATH(FREETYPE_INCLUDE_DIR ft2build.h
HINTS
${PC_FREETYPE_INCLUDEDIR}
${PC_FREETYPE_INCLUDE_DIRS}
PATH_SUFFIXES freetype2
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
FIND_LIBRARY(FREETYPE_LIBRARIES NAMES freetype
HINTS
${PC_FREETYPE_LIBDIR}
${PC_FREETYPE_LIBRARY_DIRS}
PATH_SUFFIXES lib64 lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
SET(FREETYPE_LIBRARIES ${FREETYPE_LIBRARIES})
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(FREETYPE DEFAULT_MSG FREETYPE_LIBRARIES FREETYPE_INCLUDE_DIR)
MARK_AS_ADVANCED(FREETYPE_INCLUDE_DIR FREETYPE_LIBRARIES)
# - Try to find the Lib library
# Once done this will define
#
# IRRLICHT_FOUND - System has IRRLICHT
# IRRLICHT_INCLUDE_DIR - The IRRLICHT include directory
# IRRLICHT_LIBRARIES - The libraries needed to use IRRLICHT
# IRRLICHT_DEFINITIONS - Compiler switches required for using IRRLICHT
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
#FIND_PACKAGE(PkgConfig)
#PKG_SEARCH_MODULE(PC_IRRLICHT Irrlicht)
SET(IRRLICHT_DEFINITIONS ${PC_IRRLICHT_CFLAGS_OTHER})
FIND_PATH(IRRLICHT_INCLUDE_DIR irrlicht.h
HINTS
${PC_IRRLICHT_INCLUDEDIR}
${PC_IRRLICHT_INCLUDE_DIRS}
PATH_SUFFIXES include include/irrlicht
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
FIND_LIBRARY(IRRLICHT_LIBRARIES NAMES Irrlicht irrlicht
HINTS
${PC_IRRLICHT_LIBDIR}
${PC_IRRLICHT_LIBRARY_DIRS}
PATH_SUFFIXES lib64 lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Irrlicht DEFAULT_MSG IRRLICHT_LIBRARIES IRRLICHT_INCLUDE_DIR)
MARK_AS_ADVANCED(IRRLICHT_INCLUDE_DIR IRRLICHT_LIBRARIES)
# - Try to find the Lib library
# Once done this will define
#
# LIBEVENT_FOUND - System has Libevent
# LIBEVENT_INCLUDE_DIR - The Libevent include directory
# LIBEVENT_LIBRARIES - The libraries needed to use Libevent
# LIBEVENT_DEFINITIONS - Compiler switches required for using Libevent
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
#FIND_PACKAGE(PkgConfig)
#PKG_SEARCH_MODULE(PC_LIBEVENT event)
SET(LIBEVENT_DEFINITIONS ${PC_LIBEVENT_CFLAGS_OTHER})
FIND_PATH(LIBEVENT_INCLUDE_DIR event2/event.h
HINTS
${PC_LIBEVENT_INCLUDEDIR}
${PC_LIBEVENT_INCLUDE_DIRS}
PATH_SUFFIXES include
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
FIND_LIBRARY(LIBEVENT_LIBRARIES NAMES event
HINTS
${PC_LIBEVENT_LIBDIR}
${PC_LIBEVENT_LIBRARY_DIRS}
PATH_SUFFIXES lib64 lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
FIND_LIBRARY(LIBEVENT_LIBRARIES_PTHREADS NAMES event_pthreads
HINTS
${PC_LIBEVENT_LIBDIR}
${PC_LIBEVENT_LIBRARY_DIRS}
PATH_SUFFIXES lib64 lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
SET(LIBEVENT_LIBRARIES ${LIBEVENT_LIBRARIES} ${LIBEVENT_LIBRARIES_PTHREADS})
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibEvent DEFAULT_MSG LIBEVENT_LIBRARIES LIBEVENT_INCLUDE_DIR)
MARK_AS_ADVANCED(LIBEVENT_INCLUDE_DIR LIBEVENT_LIBRARIES)
# - Try to find the Lib library
# Once done this will define
#
# SQLITE_FOUND - System has sqlite
# SQLITE_INCLUDE_DIR - The sqlite include directory
# SQLITE_LIBRARIES - The libraries needed to use sqlite
# SQLITE_DEFINITIONS - Compiler switches required for using sqlite
SET(SQLITE_DEFINITIONS ${PC_SQLITE_CFLAGS_OTHER})
FIND_PATH(SQLITE_INCLUDE_DIR sqlite3.h
HINTS
${PC_SQLITE_INCLUDEDIR}
${PC_SQLITE_INCLUDE_DIRS}
PATH_SUFFIXES include
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
FIND_LIBRARY(SQLITE_LIBRARIES NAMES sqlite3
HINTS
${PC_SQLITE_LIBDIR}
${PC_SQLITE_LIBRARY_DIRS}
PATH_SUFFIXES lib64 lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/opt/local
)
SET(SQLITE_LIBRARIES ${SQLITE_LIBRARIES})
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SQLITE DEFAULT_MSG SQLITE_LIBRARIES SQLITE_INCLUDE_DIR)
MARK_AS_ADVANCED(SQLITE_INCLUDE_DIR SQLITE_LIBRARIES)
# - Combine lists of prefixes and suffixes in all combinations
#
# list_combinations(var PREFIXES listitems... SUFFIXES listitems...) -
# where var is the name of your desired output variable and PREFIXES
# and SUFFIXES are special arguments that indicate the start of your
# list of prefixes or suffixes respectively.
#
# Original Author:
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
if(__list_combinations)
return()
endif()
set(__list_combinations YES)
function(list_combinations var)
# Parse arguments
set(_prefixes)
set(_suffixes)
set(_nowhere)
set(_curdest _nowhere)
foreach(_element ${ARGN})
if("${_element}" STREQUAL "PREFIXES")
set(_curdest _prefixes)
elseif("${_element}" STREQUAL "SUFFIXES")
set(_curdest _suffixes)
else()
list(APPEND ${_curdest} "${_element}")
endif()
endforeach()
if(_nowhere)
message(STATUS "_prefixes ${_prefixes}")
message(STATUS "_prefixes ${_suffixes}")
message(STATUS "_prefixes ${_nowhere}")
message(FATAL_ERROR
"Syntax error in use of ${CMAKE_CURRENT_LIST_FILE}")
endif()
foreach(_prefix ${_prefixes})
foreach(_suffix ${_suffixes})
list(APPEND _out "${_prefix}${_suffix}")
endforeach()
endforeach()
set(${var} "${_out}" PARENT_SCOPE)
endfunction()
# - Compile with multiple processes on MSVC
#
# include(MSVCMultipleProcessCompile)
#
# Requires these CMake modules:
# ListCombinations.cmake
#
# Original Author:
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
if(MSVC AND NOT "${MSVC_VERSION}" LESS 1400)
# Only available in VS 2005 and newer
string(TOUPPER "${CMAKE_CONFIGURATION_TYPES}" _conftypesUC)
include(ListCombinations)
list_combinations(_varnames
PREFIXES
CMAKE_C_FLAGS_
CMAKE_CXX_FLAGS_
SUFFIXES
${_conftypesUC})
foreach(_var ${_varnames})
set(${_var} "${${_var}} /MP")
endforeach()
endif()
# - Modify compile flags to use the static runtimes of MSVC
#
# include(MSVCStaticRuntime)
#
# Requires these CMake modules:
# ListCombinations.cmake
#
# Original Author:
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
if(MSVC)
string(TOUPPER "${CMAKE_CONFIGURATION_TYPES}" _conftypesUC)
include(ListCombinations)
list_combinations(_varnames
PREFIXES
CMAKE_C_FLAGS_
CMAKE_CXX_FLAGS_
SUFFIXES
${_conftypesUC})
foreach(_var ${_varnames})
string(REPLACE "/MDd" "/MTd" ${_var} "${${_var}}")
string(REPLACE "/MD" "/MT" ${_var} "${${_var}}")
endforeach()
endif()
set(Boost_USE_STATIC_LIBS ON)
add_definitions ( "-DLUA_USE_MACOSX" )
add_definitions ( "-DLUA_USE_POSIX" )
add_definitions ( "-DLUA_USE_LINUX" )
if(CMAKE_SIZEOF_VOID_P MATCHES 8)
set(PLATFORM 64)
MESSAGE(STATUS "Detected 64-bit platform")
else()
set(PLATFORM 32)
MESSAGE(STATUS "Detected 32-bit platform")
endif()
if(WIN32)
include(platform/win)
elseif(UNIX)
include(platform/unix)
endif()
if (APPLE)
include (platform/apple)
if ("${CMAKE_GENERATOR}" MATCHES "Xcode")
include (platform/xcode)
endif ()
elseif (CMAKE_SYSTEM MATCHES Linux)
include (platform/linux)
else ()
include (platform/common)
endif ()
if(CMAKE_C_COMPILER MATCHES "icc")
include(compiler/icc)
elseif(CMAKE_C_COMPILER MATCHES "clang")
include(compiler/clang-compile)
elseif(CMAKE_C_COMPILER MATCHES "cc")
include(compiler/gcc)
endif()
find_package(Threads)
find_package(DL)
if ( MSVC )
include(compiler/msvc)
elseif ( MINGW )
if(CMAKE_C_COMPILER MATCHES "clang")
include(compiler/clang)
elseif(CMAKE_C_COMPILER MATCHES "cc")
include(compiler/gcc)
endif()
include(compiler/mingw)
endif()
set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvm.clang.1_0")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++14")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
project (ygopro)
if (NOT WIN32 AND NOT APPLE)
include (FindX11)
endif ()
add_subdirectory (lzma)
set (AUTO_FILES_RESULT)
if (MSVC)
AutoFiles("." "res" "\\.(rc)$")
AutoFiles("." "src" "\\.(cpp|c|h)$" "CGUIButton.cpp|lzma/\\.*")
else ()
AutoFiles("." "src" "\\.(cpp|c|h)$" "lzma/\\.*")
endif ()
if (MSVC)
add_executable (ygopro WIN32 ${AUTO_FILES_RESULT})
set_target_properties (ygopro PROPERTIES LINK_FLAGS /ENTRY:"mainCRTStartup")
else ()
add_executable (ygopro ${AUTO_FILES_RESULT})
endif ()
target_link_libraries (ygopro ocgcore lua clzma)
if (MSVC)
target_link_libraries (ygopro irrlicht freetype sqlite3 event)
include_directories ( "../irrlicht/include" "../freetype/include" "../event/include" "../sqlite3" )
else ()
target_link_libraries (ygopro
${IRRLICHT_LIBRARIES}
${FREETYPE_LIBRARIES}
${SQLITE_LIBRARIES}
${LIBEVENT_LIBRARIES}
${OPENGL_gl_LIBRARY}
)
include_directories (
${IRRLICHT_INCLUDE_DIR}
${FREETYPE_INCLUDE_DIR}
${SQLITE_INCLUDE_DIRS}
${LIBEVENT_INCLUDE_DIR}
${OPENGL_INCLUDE_DIR}
)
target_link_libraries (ygopro ${CMAKE_THREAD_LIBS_INIT} ${DL_LIBRARIES})
endif ()
if (USE_IRRKLANG)
add_definitions ( "-DYGOPRO_USE_IRRKLANG" )
if (MSVC)
target_link_libraries (ygopro ${IRRKLANG_DIR}/lib/Win32-visualStudio/irrKlang.lib)
elseif (CMAKE_SYSTEM MATCHES Linux)
target_link_libraries (ygopro ${IRRKLANG_DIR}/bin/linux-gcc-64/libIrrKlang.so)
endif ()
include_directories ( "${IRRKLANG_DIR}/include" )
endif ()
if (WIN32)
target_link_libraries (ygopro ws2_32 winmm gdi32 kernel32 user32 imm32 opengl32)
endif ()
...@@ -60,7 +60,7 @@ public: ...@@ -60,7 +60,7 @@ public:
*pstr = 0; *pstr = 0;
return l; return l;
} }
// UCS-2 to UTF-8 // UTF-16/UTF-32 to UTF-8
static int EncodeUTF8(const wchar_t * wsrc, char * str) { static int EncodeUTF8(const wchar_t * wsrc, char * str) {
char* pstr = str; char* pstr = str;
while(*wsrc != 0) { while(*wsrc != 0) {
...@@ -71,18 +71,35 @@ public: ...@@ -71,18 +71,35 @@ public:
str[0] = ((*wsrc >> 6) & 0x1f) | 0xc0; str[0] = ((*wsrc >> 6) & 0x1f) | 0xc0;
str[1] = ((*wsrc) & 0x3f) | 0x80; str[1] = ((*wsrc) & 0x3f) | 0x80;
str += 2; str += 2;
} else { } else if(*wsrc < 0x10000 && (*wsrc < 0xd800 || *wsrc > 0xdfff)) {
str[0] = ((*wsrc >> 12) & 0xf) | 0xe0; str[0] = ((*wsrc >> 12) & 0xf) | 0xe0;
str[1] = ((*wsrc >> 6) & 0x3f) | 0x80; str[1] = ((*wsrc >> 6) & 0x3f) | 0x80;
str[2] = ((*wsrc) & 0x3f) | 0x80; str[2] = ((*wsrc) & 0x3f) | 0x80;
str += 3; str += 3;
} else {
#ifdef _WIN32
unsigned unicode = 0;
unicode |= (*wsrc++ & 0x3ff) << 10;
unicode |= *wsrc & 0x3ff;
unicode += 0x10000;
str[0] = ((unicode >> 18) & 0x7) | 0xf0;
str[1] = ((unicode >> 12) & 0x3f) | 0x80;
str[2] = ((unicode >> 6) & 0x3f) | 0x80;
str[3] = ((unicode) & 0x3f) | 0x80;
#else
str[0] = ((*wsrc >> 18) & 0x7) | 0xf0;
str[1] = ((*wsrc >> 12) & 0x3f) | 0x80;
str[2] = ((*wsrc >> 6) & 0x3f) | 0x80;
str[3] = ((*wsrc) & 0x3f) | 0x80;
#endif // _WIN32
str += 4;
} }
wsrc++; wsrc++;
} }
*str = 0; *str = 0;
return str - pstr; return str - pstr;
} }
// UTF-8 to UCS-2 // UTF-8 to UTF-16/UTF-32
static int DecodeUTF8(const char * src, wchar_t * wstr) { static int DecodeUTF8(const char * src, wchar_t * wstr) {
const char* p = src; const char* p = src;
wchar_t* wp = wstr; wchar_t* wp = wstr;
...@@ -97,7 +114,14 @@ public: ...@@ -97,7 +114,14 @@ public:
*wp = (((unsigned)p[0] & 0xf) << 12) | (((unsigned)p[1] & 0x3f) << 6) | ((unsigned)p[2] & 0x3f); *wp = (((unsigned)p[0] & 0xf) << 12) | (((unsigned)p[1] & 0x3f) << 6) | ((unsigned)p[2] & 0x3f);
p += 3; p += 3;
} else if((*p & 0xf8) == 0xf0) { } else if((*p & 0xf8) == 0xf0) {
#ifdef _WIN32
unsigned unicode = (((unsigned)p[0] & 0x7) << 18) | (((unsigned)p[1] & 0x3f) << 12) | (((unsigned)p[2] & 0x3f) << 6) | ((unsigned)p[3] & 0x3f);
unicode -= 0x10000;
*wp++ = (unicode >> 10) | 0xd800;
*wp = (unicode & 0x3ff) | 0xdc00;
#else
*wp = (((unsigned)p[0] & 0x7) << 18) | (((unsigned)p[1] & 0x3f) << 12) | (((unsigned)p[2] & 0x3f) << 6) | ((unsigned)p[3] & 0x3f); *wp = (((unsigned)p[0] & 0x7) << 18) | (((unsigned)p[1] & 0x3f) << 12) | (((unsigned)p[2] & 0x3f) << 6) | ((unsigned)p[3] & 0x3f);
#endif // _WIN32
p += 4; p += 4;
} else } else
p++; p++;
......
...@@ -18,7 +18,7 @@ ClientCard::ClientCard() { ...@@ -18,7 +18,7 @@ ClientCard::ClientCard() {
is_showtarget = false; is_showtarget = false;
is_showchaintarget = false; is_showchaintarget = false;
is_highlighting = false; is_highlighting = false;
is_disabled = false; status = 0;
is_reversed = false; is_reversed = false;
cmdFlag = 0; cmdFlag = 0;
code = 0; code = 0;
...@@ -38,6 +38,7 @@ ClientCard::ClientCard() { ...@@ -38,6 +38,7 @@ ClientCard::ClientCard() {
lscale = 0; lscale = 0;
rscale = 0; rscale = 0;
link_marker = 0; link_marker = 0;
position = 0;
cHint = 0; cHint = 0;
chValue = 0; chValue = 0;
atkstring[0] = 0; atkstring[0] = 0;
...@@ -70,8 +71,12 @@ void ClientCard::UpdateInfo(char* buf) { ...@@ -70,8 +71,12 @@ void ClientCard::UpdateInfo(char* buf) {
code = pdata; code = pdata;
} }
if(flag & QUERY_POSITION) { if(flag & QUERY_POSITION) {
pdata = BufferIO::ReadInt32(buf); pdata = (BufferIO::ReadInt32(buf) >> 24) & 0xff;
position = (pdata >> 24) & 0xff; if((location & (LOCATION_EXTRA | LOCATION_REMOVED)) && (u8)pdata != position) {
position = pdata;
mainGame->dField.MoveCard(this, 1);
} else
position = pdata;
} }
if(flag & QUERY_ALIAS) if(flag & QUERY_ALIAS)
alias = BufferIO::ReadInt32(buf); alias = BufferIO::ReadInt32(buf);
...@@ -120,6 +125,8 @@ void ClientCard::UpdateInfo(char* buf) { ...@@ -120,6 +125,8 @@ void ClientCard::UpdateInfo(char* buf) {
base_defense = BufferIO::ReadInt32(buf); base_defense = BufferIO::ReadInt32(buf);
if(flag & QUERY_REASON) if(flag & QUERY_REASON)
reason = BufferIO::ReadInt32(buf); reason = BufferIO::ReadInt32(buf);
if(flag & QUERY_REASON_CARD)
buf += 4;
if(flag & QUERY_EQUIP_CARD) { if(flag & QUERY_EQUIP_CARD) {
int c = BufferIO::ReadInt8(buf); int c = BufferIO::ReadInt8(buf);
int l = BufferIO::ReadInt8(buf); int l = BufferIO::ReadInt8(buf);
...@@ -157,10 +164,8 @@ void ClientCard::UpdateInfo(char* buf) { ...@@ -157,10 +164,8 @@ void ClientCard::UpdateInfo(char* buf) {
} }
if(flag & QUERY_OWNER) if(flag & QUERY_OWNER)
owner = BufferIO::ReadInt32(buf); owner = BufferIO::ReadInt32(buf);
if(flag & QUERY_IS_DISABLED) if(flag & QUERY_STATUS)
is_disabled = BufferIO::ReadInt32(buf); status = BufferIO::ReadInt32(buf);
if(flag & QUERY_IS_PUBLIC)
is_public = BufferIO::ReadInt32(buf);
if(flag & QUERY_LSCALE) { if(flag & QUERY_LSCALE) {
lscale = BufferIO::ReadInt32(buf); lscale = BufferIO::ReadInt32(buf);
myswprintf(lscstring, L"%d", lscale); myswprintf(lscstring, L"%d", lscale);
...@@ -205,8 +210,14 @@ bool ClientCard::client_card_sort(ClientCard* c1, ClientCard* c2) { ...@@ -205,8 +210,14 @@ bool ClientCard::client_card_sort(ClientCard* c1, ClientCard* c2) {
return c1->overlayTarget->sequence < c2->overlayTarget->sequence; return c1->overlayTarget->sequence < c2->overlayTarget->sequence;
else return c1->sequence < c2->sequence; else return c1->sequence < c2->sequence;
else { else {
if(c1->location & 0x71) if(c1->location & (LOCATION_DECK | LOCATION_GRAVE | LOCATION_REMOVED | LOCATION_EXTRA)) {
for(size_t i = 0; i < mainGame->dField.chains.size(); ++i) {
auto chit = mainGame->dField.chains[i];
if(c1 == chit.chain_card || chit.target.find(c1) != chit.target.end())
return true;
}
return c1->sequence > c2->sequence; return c1->sequence > c2->sequence;
}
else else
return c1->sequence < c2->sequence; return c1->sequence < c2->sequence;
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "config.h" #include "config.h"
#include <vector> #include <vector>
#include <set> #include <set>
#include <map>
#include <unordered_map> #include <unordered_map>
namespace ygo { namespace ygo {
...@@ -88,8 +89,7 @@ public: ...@@ -88,8 +89,7 @@ public:
u8 location; u8 location;
u8 sequence; u8 sequence;
u8 position; u8 position;
u8 is_disabled; u32 status;
u8 is_public;
u8 cHint; u8 cHint;
u32 chValue; u32 chValue;
u32 opParam; u32 opParam;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include "image_manager.h" #include "image_manager.h"
#include "game.h" #include "game.h"
#include "materials.h" #include "materials.h"
#include "../ocgcore/field.h" #include "../ocgcore/common.h"
namespace ygo { namespace ygo {
...@@ -303,7 +303,6 @@ void ClientField::UpdateCard(int controler, int location, int sequence, char* da ...@@ -303,7 +303,6 @@ void ClientField::UpdateCard(int controler, int location, int sequence, char* da
} }
void ClientField::UpdateFieldCard(int controler, int location, char* data) { void ClientField::UpdateFieldCard(int controler, int location, char* data) {
std::vector<ClientCard*>* lst = 0; std::vector<ClientCard*>* lst = 0;
std::vector<ClientCard*>::iterator cit;
switch(location) { switch(location) {
case LOCATION_DECK: case LOCATION_DECK:
lst = &deck[controler]; lst = &deck[controler];
...@@ -330,7 +329,7 @@ void ClientField::UpdateFieldCard(int controler, int location, char* data) { ...@@ -330,7 +329,7 @@ void ClientField::UpdateFieldCard(int controler, int location, char* data) {
if(!lst) if(!lst)
return; return;
int len; int len;
for(cit = lst->begin(); cit != lst->end(); ++cit) { for(auto cit = lst->begin(); cit != lst->end(); ++cit) {
len = BufferIO::ReadInt32(data); len = BufferIO::ReadInt32(data);
if(len > 8) if(len > 8)
(*cit)->UpdateInfo(data); (*cit)->UpdateInfo(data);
...@@ -338,20 +337,19 @@ void ClientField::UpdateFieldCard(int controler, int location, char* data) { ...@@ -338,20 +337,19 @@ void ClientField::UpdateFieldCard(int controler, int location, char* data) {
} }
} }
void ClientField::ClearCommandFlag() { void ClientField::ClearCommandFlag() {
std::vector<ClientCard*>::iterator cit; for(auto cit = activatable_cards.begin(); cit != activatable_cards.end(); ++cit)
for(cit = activatable_cards.begin(); cit != activatable_cards.end(); ++cit)
(*cit)->cmdFlag = 0; (*cit)->cmdFlag = 0;
for(cit = summonable_cards.begin(); cit != summonable_cards.end(); ++cit) for(auto cit = summonable_cards.begin(); cit != summonable_cards.end(); ++cit)
(*cit)->cmdFlag = 0; (*cit)->cmdFlag = 0;
for(cit = spsummonable_cards.begin(); cit != spsummonable_cards.end(); ++cit) for(auto cit = spsummonable_cards.begin(); cit != spsummonable_cards.end(); ++cit)
(*cit)->cmdFlag = 0; (*cit)->cmdFlag = 0;
for(cit = msetable_cards.begin(); cit != msetable_cards.end(); ++cit) for(auto cit = msetable_cards.begin(); cit != msetable_cards.end(); ++cit)
(*cit)->cmdFlag = 0; (*cit)->cmdFlag = 0;
for(cit = ssetable_cards.begin(); cit != ssetable_cards.end(); ++cit) for(auto cit = ssetable_cards.begin(); cit != ssetable_cards.end(); ++cit)
(*cit)->cmdFlag = 0; (*cit)->cmdFlag = 0;
for(cit = reposable_cards.begin(); cit != reposable_cards.end(); ++cit) for(auto cit = reposable_cards.begin(); cit != reposable_cards.end(); ++cit)
(*cit)->cmdFlag = 0; (*cit)->cmdFlag = 0;
for(cit = attackable_cards.begin(); cit != attackable_cards.end(); ++cit) for(auto cit = attackable_cards.begin(); cit != attackable_cards.end(); ++cit)
(*cit)->cmdFlag = 0; (*cit)->cmdFlag = 0;
conti_cards.clear(); conti_cards.clear();
deck_act = false; deck_act = false;
...@@ -363,21 +361,20 @@ void ClientField::ClearCommandFlag() { ...@@ -363,21 +361,20 @@ void ClientField::ClearCommandFlag() {
conti_act = false; conti_act = false;
} }
void ClientField::ClearSelect() { void ClientField::ClearSelect() {
std::vector<ClientCard*>::iterator cit; for(auto cit = selectable_cards.begin(); cit != selectable_cards.end(); ++cit) {
for(cit = selectable_cards.begin(); cit != selectable_cards.end(); ++cit) {
(*cit)->is_selectable = false; (*cit)->is_selectable = false;
(*cit)->is_selected = false; (*cit)->is_selected = false;
} }
} }
void ClientField::ClearChainSelect() { void ClientField::ClearChainSelect() {
std::vector<ClientCard*>::iterator cit; for(auto cit = activatable_cards.begin(); cit != activatable_cards.end(); ++cit) {
for(cit = activatable_cards.begin(); cit != activatable_cards.end(); ++cit) {
(*cit)->cmdFlag = 0; (*cit)->cmdFlag = 0;
(*cit)->chain_code = 0; (*cit)->chain_code = 0;
(*cit)->is_selectable = false; (*cit)->is_selectable = false;
(*cit)->is_selected = false; (*cit)->is_selected = false;
} }
conti_cards.clear(); conti_cards.clear();
deck_act = false;
grave_act = false; grave_act = false;
remove_act = false; remove_act = false;
extra_act = false; extra_act = false;
...@@ -402,7 +399,7 @@ void ClientField::ShowSelectCard(bool buttonok, bool chain) { ...@@ -402,7 +399,7 @@ void ClientField::ShowSelectCard(bool buttonok, bool chain) {
else if(conti_selecting) else if(conti_selecting)
mainGame->imageLoading.insert(std::make_pair(mainGame->btnCardSelect[i], selectable_cards[i]->chain_code)); mainGame->imageLoading.insert(std::make_pair(mainGame->btnCardSelect[i], selectable_cards[i]->chain_code));
else else
mainGame->btnCardSelect[i]->setImage(imageManager.tCover[0]); mainGame->btnCardSelect[i]->setImage(imageManager.tCover[selectable_cards[i]->controler]);
mainGame->btnCardSelect[i]->setRelativePosition(rect<s32>(startpos + i * 125, 55, startpos + 120 + i * 125, 225)); mainGame->btnCardSelect[i]->setRelativePosition(rect<s32>(startpos + i * 125, 55, startpos + 120 + i * 125, 225));
mainGame->btnCardSelect[i]->setPressed(false); mainGame->btnCardSelect[i]->setPressed(false);
mainGame->btnCardSelect[i]->setVisible(true); mainGame->btnCardSelect[i]->setVisible(true);
...@@ -486,7 +483,7 @@ void ClientField::ShowChainCard() { ...@@ -486,7 +483,7 @@ void ClientField::ShowChainCard() {
if(selectable_cards[i]->code) if(selectable_cards[i]->code)
mainGame->imageLoading.insert(std::make_pair(mainGame->btnCardSelect[i], selectable_cards[i]->code)); mainGame->imageLoading.insert(std::make_pair(mainGame->btnCardSelect[i], selectable_cards[i]->code));
else else
mainGame->btnCardSelect[i]->setImage(imageManager.tCover[0]); mainGame->btnCardSelect[i]->setImage(imageManager.tCover[selectable_cards[i]->controler]);
mainGame->btnCardSelect[i]->setRelativePosition(rect<s32>(startpos + i * 125, 55, startpos + 120 + i * 125, 225)); mainGame->btnCardSelect[i]->setRelativePosition(rect<s32>(startpos + i * 125, 55, startpos + 120 + i * 125, 225));
mainGame->btnCardSelect[i]->setPressed(false); mainGame->btnCardSelect[i]->setPressed(false);
mainGame->btnCardSelect[i]->setVisible(true); mainGame->btnCardSelect[i]->setVisible(true);
...@@ -541,7 +538,7 @@ void ClientField::ShowLocationCard() { ...@@ -541,7 +538,7 @@ void ClientField::ShowLocationCard() {
if(display_cards[i]->code) if(display_cards[i]->code)
mainGame->imageLoading.insert(std::make_pair(mainGame->btnCardDisplay[i], display_cards[i]->code)); mainGame->imageLoading.insert(std::make_pair(mainGame->btnCardDisplay[i], display_cards[i]->code));
else else
mainGame->btnCardDisplay[i]->setImage(imageManager.tCover[0]); mainGame->btnCardDisplay[i]->setImage(imageManager.tCover[display_cards[i]->controler]);
mainGame->btnCardDisplay[i]->setRelativePosition(rect<s32>(startpos + i * 125, 55, startpos + 120 + i * 125, 225)); mainGame->btnCardDisplay[i]->setRelativePosition(rect<s32>(startpos + i * 125, 55, startpos + 120 + i * 125, 225));
mainGame->btnCardDisplay[i]->setPressed(false); mainGame->btnCardDisplay[i]->setPressed(false);
mainGame->btnCardDisplay[i]->setVisible(true); mainGame->btnCardDisplay[i]->setVisible(true);
...@@ -593,6 +590,55 @@ void ClientField::ShowLocationCard() { ...@@ -593,6 +590,55 @@ void ClientField::ShowLocationCard() {
mainGame->btnDisplayOK->setVisible(true); mainGame->btnDisplayOK->setVisible(true);
mainGame->PopupElement(mainGame->wCardDisplay); mainGame->PopupElement(mainGame->wCardDisplay);
} }
void ClientField::ShowSelectOption(int select_hint) {
selected_option = 0;
wchar_t textBuffer[256];
int count = select_options.size();
bool quickmode = (count <= 5);
mainGame->gMutex.Lock();
for(int i = 0; (i < count) && quickmode; i++) {
const wchar_t* option = dataManager.GetDesc(select_options[i]);
irr::core::dimension2d<unsigned int> dtxt = mainGame->guiFont->getDimension(option);
if(dtxt.Width > 310) {
quickmode = false;
break;
}
mainGame->btnOption[i]->setText(option);
}
if(quickmode) {
mainGame->stOptions->setVisible(false);
mainGame->btnOptionp->setVisible(false);
mainGame->btnOptionn->setVisible(false);
mainGame->btnOptionOK->setVisible(false);
for(int i = 0; i < 5; i++)
mainGame->btnOption[i]->setVisible(i < count);
recti pos = mainGame->wOptions->getRelativePosition();
int newheight = 30 + 40 * count;
int oldheight = pos.LowerRightCorner.Y - pos.UpperLeftCorner.Y;
pos.UpperLeftCorner.Y = pos.UpperLeftCorner.Y + (oldheight - newheight) / 2;
pos.LowerRightCorner.Y = pos.UpperLeftCorner.Y + newheight;
mainGame->wOptions->setRelativePosition(pos);
} else {
mainGame->SetStaticText(mainGame->stOptions, 310, mainGame->guiFont,
(wchar_t*)dataManager.GetDesc(select_options[0]));
mainGame->stOptions->setVisible(true);
mainGame->btnOptionp->setVisible(false);
mainGame->btnOptionn->setVisible(count > 1);
mainGame->btnOptionOK->setVisible(true);
for(int i = 0; i < 5; i++)
mainGame->btnOption[i]->setVisible(false);
recti pos = mainGame->wOptions->getRelativePosition();
pos.LowerRightCorner.Y = pos.UpperLeftCorner.Y + 140;
mainGame->wOptions->setRelativePosition(pos);
}
if(select_hint)
myswprintf(textBuffer, L"%ls", dataManager.GetDesc(select_hint));
else
myswprintf(textBuffer, dataManager.GetSysString(555));
mainGame->wOptions->setText(textBuffer);
mainGame->PopupElement(mainGame->wOptions);
mainGame->gMutex.Unlock();
}
void ClientField::ReplaySwap() { void ClientField::ReplaySwap() {
std::swap(deck[0], deck[1]); std::swap(deck[0], deck[1]);
std::swap(hand[0], hand[1]); std::swap(hand[0], hand[1]);
...@@ -1062,7 +1108,7 @@ bool ClientField::ShowSelectSum(bool panelmode) { ...@@ -1062,7 +1108,7 @@ bool ClientField::ShowSelectSum(bool panelmode) {
select_ready = false; select_ready = false;
} }
if (select_ready) { if (select_ready) {
ShowCancelOrFinishButton(1); ShowCancelOrFinishButton(2);
} else { } else {
ShowCancelOrFinishButton(0); ShowCancelOrFinishButton(0);
} }
...@@ -1378,8 +1424,23 @@ void ClientField::UpdateDeclarableCodeType(bool enter) { ...@@ -1378,8 +1424,23 @@ void ClientField::UpdateDeclarableCodeType(bool enter) {
ancard.push_back(trycode); ancard.push_back(trycode);
return; return;
} }
if((pname[0] == 0 || pname[1] == 0) && !enter) if((pname[0] == 0 || pname[1] == 0) && !enter) {
return; std::vector<int> cache;
cache.swap(ancard);
int sel = mainGame->lstANCard->getSelected();
int selcode = (sel == -1) ? 0 : cache[sel];
mainGame->lstANCard->clear();
for(const auto& trycode : cache) {
if(dataManager.GetString(trycode, &cstr) && dataManager.GetData(trycode, &cd) && is_declarable(cd, declarable_type)) {
ancard.push_back(trycode);
mainGame->lstANCard->addItem(cstr.name.c_str());
if(trycode == selcode)
mainGame->lstANCard->setSelected(cstr.name.c_str());
}
}
if(!ancard.empty())
return;
}
mainGame->lstANCard->clear(); mainGame->lstANCard->clear();
ancard.clear(); ancard.clear();
for(auto cit = dataManager._strings.begin(); cit != dataManager._strings.end(); ++cit) { for(auto cit = dataManager._strings.begin(); cit != dataManager._strings.end(); ++cit) {
...@@ -1410,8 +1471,23 @@ void ClientField::UpdateDeclarableCodeOpcode(bool enter) { ...@@ -1410,8 +1471,23 @@ void ClientField::UpdateDeclarableCodeOpcode(bool enter) {
ancard.push_back(trycode); ancard.push_back(trycode);
return; return;
} }
if((pname[0] == 0 || pname[1] == 0) && !enter) if((pname[0] == 0 || pname[1] == 0) && !enter) {
return; std::vector<int> cache;
cache.swap(ancard);
int sel = mainGame->lstANCard->getSelected();
int selcode = (sel == -1) ? 0 : cache[sel];
mainGame->lstANCard->clear();
for(const auto& trycode : cache) {
if(dataManager.GetString(trycode, &cstr) && dataManager.GetData(trycode, &cd) && is_declarable(cd, opcode)) {
ancard.push_back(trycode);
mainGame->lstANCard->addItem(cstr.name.c_str());
if(trycode == selcode)
mainGame->lstANCard->setSelected(cstr.name.c_str());
}
}
if(!ancard.empty())
return;
}
mainGame->lstANCard->clear(); mainGame->lstANCard->clear();
ancard.clear(); ancard.clear();
for(auto cit = dataManager._strings.begin(); cit != dataManager._strings.end(); ++cit) { for(auto cit = dataManager._strings.begin(); cit != dataManager._strings.end(); ++cit) {
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "config.h" #include "config.h"
#include <vector> #include <vector>
#include <set> #include <set>
#include <map>
namespace ygo { namespace ygo {
...@@ -54,8 +55,8 @@ public: ...@@ -54,8 +55,8 @@ public:
int select_max; int select_max;
int must_select_count; int must_select_count;
int select_sumval; int select_sumval;
int select_cancelable;
int select_mode; int select_mode;
bool select_cancelable;
bool select_panalmode; bool select_panalmode;
bool select_ready; bool select_ready;
int announce_count; int announce_count;
...@@ -96,6 +97,7 @@ public: ...@@ -96,6 +97,7 @@ public:
void ShowSelectCard(bool buttonok = false, bool chain = false); void ShowSelectCard(bool buttonok = false, bool chain = false);
void ShowChainCard(); void ShowChainCard();
void ShowLocationCard(); void ShowLocationCard();
void ShowSelectOption(int select_hint = 0);
void ReplaySwap(); void ReplaySwap();
void RefreshAllCards(); void RefreshAllCards();
...@@ -136,7 +138,9 @@ public: ...@@ -136,7 +138,9 @@ public:
void UpdateChainButtons(); void UpdateChainButtons();
void ShowCancelOrFinishButton(int buttonOp); void ShowCancelOrFinishButton(int buttonOp);
void SetShowMark(ClientCard* pcard, bool enable); void SetShowMark(ClientCard* pcard, bool enable);
void ShowCardInfoInList(ClientCard* pcard, irr::gui::IGUIElement* element, irr::gui::IGUIElement* parent);
void SetResponseSelectedCards() const; void SetResponseSelectedCards() const;
void SetResponseSelectedOption() const;
void CancelOrFinish(); void CancelOrFinish();
}; };
......
...@@ -12,11 +12,9 @@ ...@@ -12,11 +12,9 @@
#include <ws2tcpip.h> #include <ws2tcpip.h>
#ifdef _MSC_VER #ifdef _MSC_VER
#define myswprintf _swprintf
#define mywcsncasecmp _wcsnicmp #define mywcsncasecmp _wcsnicmp
#define mystrncasecmp _strnicmp #define mystrncasecmp _strnicmp
#else #else
#define myswprintf swprintf
#define mywcsncasecmp wcsncasecmp #define mywcsncasecmp wcsncasecmp
#define mystrncasecmp strncasecmp #define mystrncasecmp strncasecmp
#endif #endif
...@@ -44,7 +42,6 @@ ...@@ -44,7 +42,6 @@
#define SOCKET_ERRNO() (errno) #define SOCKET_ERRNO() (errno)
#include <wchar.h> #include <wchar.h>
#define myswprintf(buf, fmt, ...) swprintf(buf, 4096, fmt, ##__VA_ARGS__)
#define mywcsncasecmp wcsncasecmp #define mywcsncasecmp wcsncasecmp
#define mystrncasecmp strncasecmp #define mystrncasecmp strncasecmp
inline int _wtoi(const wchar_t * s) { inline int _wtoi(const wchar_t * s) {
...@@ -53,6 +50,11 @@ inline int _wtoi(const wchar_t * s) { ...@@ -53,6 +50,11 @@ inline int _wtoi(const wchar_t * s) {
} }
#endif #endif
template<size_t N, typename... TR>
inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
return swprintf(buf, N, fmt, args...);
}
#include <irrlicht.h> #include <irrlicht.h>
#include <GL/gl.h> #include <GL/gl.h>
#include <GL/glu.h> #include <GL/glu.h>
...@@ -64,11 +66,12 @@ inline int _wtoi(const wchar_t * s) { ...@@ -64,11 +66,12 @@ inline int _wtoi(const wchar_t * s) {
#include <memory.h> #include <memory.h>
#include <time.h> #include <time.h>
#include "bufferio.h" #include "bufferio.h"
#include "myfilesystem.h"
#include "mymutex.h" #include "mymutex.h"
#include "mysignal.h" #include "mysignal.h"
#include "mythread.h" #include "mythread.h"
#include "../ocgcore/ocgapi.h" #include "../ocgcore/ocgapi.h"
#include "../ocgcore/card.h" #include "../ocgcore/common.h"
using namespace irr; using namespace irr;
using namespace core; using namespace core;
......
...@@ -62,6 +62,7 @@ static bool check_set_code(const CardDataC& data, int set_code) { ...@@ -62,6 +62,7 @@ static bool check_set_code(const CardDataC& data, int set_code) {
void DeckBuilder::Initialize() { void DeckBuilder::Initialize() {
mainGame->is_building = true; mainGame->is_building = true;
mainGame->is_siding = false; mainGame->is_siding = false;
mainGame->ClearCardInfo();
mainGame->wInfos->setVisible(true); mainGame->wInfos->setVisible(true);
mainGame->wCardImg->setVisible(true); mainGame->wCardImg->setVisible(true);
mainGame->wDeckEdit->setVisible(true); mainGame->wDeckEdit->setVisible(true);
...@@ -91,6 +92,7 @@ void DeckBuilder::Initialize() { ...@@ -91,6 +92,7 @@ void DeckBuilder::Initialize() {
} }
void DeckBuilder::Terminate() { void DeckBuilder::Terminate() {
mainGame->is_building = false; mainGame->is_building = false;
mainGame->ClearCardInfo();
mainGame->wDeckEdit->setVisible(false); mainGame->wDeckEdit->setVisible(false);
mainGame->wCategories->setVisible(false); mainGame->wCategories->setVisible(false);
mainGame->wFilter->setVisible(false); mainGame->wFilter->setVisible(false);
...@@ -274,7 +276,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -274,7 +276,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1410)); mainGame->env->addMessageBox(L"", dataManager.GetSysString(1410));
break; break;
} }
mainGame->imgCard->setImage(imageManager.tCover[0]); mainGame->ClearCardInfo();
char deckbuf[1024]; char deckbuf[1024];
char* pdeck = deckbuf; char* pdeck = deckbuf;
BufferIO::WriteInt32(pdeck, deckManager.current_deck.main.size() + deckManager.current_deck.extra.size()); BufferIO::WriteInt32(pdeck, deckManager.current_deck.main.size() + deckManager.current_deck.extra.size());
...@@ -407,7 +409,8 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -407,7 +409,8 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
break; break;
} }
int sel = mainGame->cbDBDecks->getSelected(); int sel = mainGame->cbDBDecks->getSelected();
deckManager.LoadDeck(mainGame->cbDBDecks->getItem(sel)); if(sel >= 0)
deckManager.LoadDeck(mainGame->cbDBDecks->getItem(sel));
prev_deck = sel; prev_deck = sel;
is_modified = false; is_modified = false;
break; break;
...@@ -813,15 +816,34 @@ void DeckBuilder::StartFilter() { ...@@ -813,15 +816,34 @@ void DeckBuilder::StartFilter() {
void DeckBuilder::FilterCards() { void DeckBuilder::FilterCards() {
results.clear(); results.clear();
const wchar_t* pstr = mainGame->ebCardName->getText(); const wchar_t* pstr = mainGame->ebCardName->getText();
int trycode = BufferIO::GetVal(pstr); std::wstring str = std::wstring(pstr);
if(dataManager.GetData(trycode, 0)) { std::vector<std::wstring> query_elements;
auto ptr = dataManager.GetCodePointer(trycode); // verified by GetData() std::vector<std::vector<std::wstring>::iterator> query_elements_track;
results.push_back(ptr); size_t element_start = 0;
mainGame->scrFilter->setVisible(false); while(mainGame->gameConf.search_multiple_keywords) {
mainGame->scrFilter->setPos(0); size_t element_end = str.find_first_of(mainGame->gameConf.search_multiple_keywords == 1 ? L' ' : L'+', element_start);
myswprintf(result_string, L"%d", results.size()); if(element_end == std::wstring::npos)
return; break;
size_t length = element_end - element_start;
if(length > 0) {
query_elements.push_back(str.substr(element_start, length));
element_start = element_end + 1;
} else
element_start++;
}
query_elements.push_back(str.substr(element_start));
std::unordered_map<std::wstring, unsigned int> set_code_map;
for(auto elements_iterator = query_elements.begin(); elements_iterator != query_elements.end(); elements_iterator++) {
const wchar_t* element_pointer = elements_iterator->c_str();
if(element_pointer[0] == L'@')
set_code_map[*elements_iterator] = dataManager.GetSetCode(&element_pointer[1]);
else
set_code_map[*elements_iterator] = dataManager.GetSetCode(&element_pointer[0]);
if(element_pointer[0] == 0 || (element_pointer[0] == L'$' && element_pointer[1] == 0) || (element_pointer[0] == L'@' && element_pointer[1] == 0))
query_elements_track.push_back(elements_iterator);
} }
for(auto elements_track_iterator = query_elements_track.begin(); elements_track_iterator != query_elements_track.end(); elements_track_iterator++)
query_elements.erase(*elements_track_iterator);
unsigned int set_code = 0; unsigned int set_code = 0;
if(pstr[0] == L'@') if(pstr[0] == L'@')
set_code = dataManager.GetSetCode(&pstr[1]); set_code = dataManager.GetSetCode(&pstr[1]);
...@@ -902,19 +924,39 @@ void DeckBuilder::FilterCards() { ...@@ -902,19 +924,39 @@ void DeckBuilder::FilterCards() {
if(filter_lm == 7 && data.ot != 4) if(filter_lm == 7 && data.ot != 4)
continue; continue;
} }
if(pstr) { bool is_target = true;
if(pstr[0] == L'$') { for (auto elements_iterator = query_elements.begin(); elements_iterator != query_elements.end(); elements_iterator++) {
if(!CardNameContains(text.name.c_str(), &pstr[1])) const wchar_t* element_pointer = elements_iterator->c_str();
continue; if (element_pointer[0] == L'$') {
} else if(pstr[0] == L'@' && set_code) { if(!CardNameContains(text.name.c_str(), &element_pointer[1])){
if(!check_set_code(data, set_code)) continue; is_target = false;
break;
}
}
else if (element_pointer[0] == L'@' && set_code_map[*elements_iterator]) {
if(!check_set_code(data, set_code_map[*elements_iterator])) {
is_target = false;
break;
}
} else { } else {
if(!CardNameContains(text.name.c_str(), pstr) && text.text.find(pstr) == std::wstring::npos int trycode = BufferIO::GetVal(elements_iterator->c_str());
&& (!set_code || !check_set_code(data, set_code))) bool tryresult = dataManager.GetData(trycode, 0);
continue; if(!tryresult && !CardNameContains(text.name.c_str(), elements_iterator->c_str()) && text.text.find(elements_iterator->c_str()) == std::wstring::npos
&& (!set_code_map[*elements_iterator] || !check_set_code(data, set_code_map[*elements_iterator]))) {
is_target = false;
break;
}
if(tryresult && data.code != trycode
&& !(data.alias == trycode && (data.alias - data.code < CARD_ARTWORK_VERSIONS_OFFSET || data.code - data.alias < CARD_ARTWORK_VERSIONS_OFFSET))) {
is_target = false;
break;
}
} }
} }
results.push_back(ptr); if(is_target)
results.push_back(ptr);
else
continue;
} }
myswprintf(result_string, L"%d", results.size()); myswprintf(result_string, L"%d", results.size());
if(results.size() > 7) { if(results.size() > 7) {
......
...@@ -8,9 +8,9 @@ namespace ygo { ...@@ -8,9 +8,9 @@ namespace ygo {
DeckManager deckManager; DeckManager deckManager;
void DeckManager::LoadLFList() { void DeckManager::LoadLFListSingle(const char* path) {
LFList* cur = NULL; LFList* cur = NULL;
FILE* fp = fopen("lflist.conf", "r"); FILE* fp = fopen(path, "r");
char linebuf[256]; char linebuf[256];
wchar_t strBuffer[256]; wchar_t strBuffer[256];
if(fp) { if(fp) {
...@@ -24,7 +24,7 @@ void DeckManager::LoadLFList() { ...@@ -24,7 +24,7 @@ void DeckManager::LoadLFList() {
LFList newlist; LFList newlist;
_lfList.push_back(newlist); _lfList.push_back(newlist);
cur = &_lfList[_lfList.size() - 1]; cur = &_lfList[_lfList.size() - 1];
memcpy(cur->listName, (const void*)strBuffer, 40); memcpy(cur->listName, (const void*)strBuffer, 20 * sizeof(wchar_t));
cur->listName[sa] = 0; cur->listName[sa] = 0;
cur->content = new std::unordered_map<int, int>; cur->content = new std::unordered_map<int, int>;
cur->hash = 0x7dfcee6a; cur->hash = 0x7dfcee6a;
...@@ -48,6 +48,10 @@ void DeckManager::LoadLFList() { ...@@ -48,6 +48,10 @@ void DeckManager::LoadLFList() {
} }
fclose(fp); fclose(fp);
} }
}
void DeckManager::LoadLFList() {
LoadLFListSingle("expansions/lflist.conf");
LoadLFListSingle("lflist.conf");
LFList nolimit; LFList nolimit;
myswprintf(nolimit.listName, L"N/A"); myswprintf(nolimit.listName, L"N/A");
nolimit.hash = 0; nolimit.hash = 0;
...@@ -247,6 +251,8 @@ bool DeckManager::LoadDeck(const wchar_t* file) { ...@@ -247,6 +251,8 @@ bool DeckManager::LoadDeck(const wchar_t* file) {
return true; return true;
} }
bool DeckManager::SaveDeck(Deck& deck, const wchar_t* name) { bool DeckManager::SaveDeck(Deck& deck, const wchar_t* name) {
if(!FileSystem::IsDirExists(L"./deck") && !FileSystem::MakeDir(L"./deck"))
return false;
wchar_t file[64]; wchar_t file[64];
myswprintf(file, L"./deck/%ls.ydk", name); myswprintf(file, L"./deck/%ls.ydk", name);
FILE* fp = OpenDeckFile(file, "w"); FILE* fp = OpenDeckFile(file, "w");
......
...@@ -35,6 +35,7 @@ public: ...@@ -35,6 +35,7 @@ public:
Deck current_deck; Deck current_deck;
std::vector<LFList> _lfList; std::vector<LFList> _lfList;
void LoadLFListSingle(const char* path);
void LoadLFList(); void LoadLFList();
wchar_t* GetLFListName(int lfhash); wchar_t* GetLFListName(int lfhash);
int CheckDeck(Deck& deck, int lfhash, bool allow_ocg, bool allow_tcg); int CheckDeck(Deck& deck, int lfhash, bool allow_ocg, bool allow_tcg);
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "deck_manager.h" #include "deck_manager.h"
#include "sound_manager.h" #include "sound_manager.h"
#include "duelclient.h" #include "duelclient.h"
#include "../ocgcore/field.h" #include "../ocgcore/common.h"
namespace ygo { namespace ygo {
...@@ -382,7 +382,8 @@ void Game::DrawCard(ClientCard* pcard) { ...@@ -382,7 +382,8 @@ void Game::DrawCard(ClientCard* pcard) {
matManager.mTexture.setTexture(0, imageManager.tChainTarget); matManager.mTexture.setTexture(0, imageManager.tChainTarget);
driver->setMaterial(matManager.mTexture); driver->setMaterial(matManager.mTexture);
driver->drawVertexPrimitiveList(matManager.vSymbol, 4, matManager.iRectangle, 2); driver->drawVertexPrimitiveList(matManager.vSymbol, 4, matManager.iRectangle, 2);
} else if(pcard->is_disabled && (pcard->location & LOCATION_ONFIELD) && (pcard->position & POS_FACEUP)) { } else if((pcard->status & (STATUS_DISABLED | STATUS_FORBIDDEN))
&& (pcard->location & LOCATION_ONFIELD) && (pcard->position & POS_FACEUP)) {
matManager.mTexture.setTexture(0, imageManager.tNegated); matManager.mTexture.setTexture(0, imageManager.tNegated);
driver->setMaterial(matManager.mTexture); driver->setMaterial(matManager.mTexture);
driver->drawVertexPrimitiveList(matManager.vNegate, 4, matManager.iRectangle, 2); driver->drawVertexPrimitiveList(matManager.vNegate, 4, matManager.iRectangle, 2);
...@@ -681,8 +682,7 @@ void Game::DrawStatus(ClientCard* pcard, int x1, int y1, int x2, int y2) { ...@@ -681,8 +682,7 @@ void Game::DrawStatus(ClientCard* pcard, int x1, int y1, int x2, int y2) {
} }
void Game::DrawGUI() { void Game::DrawGUI() {
if(imageLoading.size()) { if(imageLoading.size()) {
std::map<irr::gui::CGUIImageButton*, int>::iterator mit; for(auto mit = imageLoading.begin(); mit != imageLoading.end(); ++mit)
for(mit = imageLoading.begin(); mit != imageLoading.end(); ++mit)
mit->first->setImage(imageManager.GetTexture(mit->second)); mit->first->setImage(imageManager.GetTexture(mit->second));
imageLoading.clear(); imageLoading.clear();
} }
...@@ -781,7 +781,7 @@ void Game::DrawSpec() { ...@@ -781,7 +781,7 @@ void Game::DrawSpec() {
} }
case 2: { case 2: {
driver->draw2DImage(imageManager.GetTexture(showcardcode), position2di(574, 150)); driver->draw2DImage(imageManager.GetTexture(showcardcode), position2di(574, 150));
driver->draw2DImage(imageManager.tMask, recti(574 + showcarddif, 150, 761, 404), recti(0, 0, CARD_IMG_WIDTH - showcarddif, CARD_IMG_HEIGHT), 0, 0, true); driver->draw2DImage(imageManager.tMask, recti(574 + showcarddif, 150, 751, 404), recti(0, 0, CARD_IMG_WIDTH - showcarddif, CARD_IMG_HEIGHT), 0, 0, true);
showcarddif += 15; showcarddif += 15;
if(showcarddif >= CARD_IMG_WIDTH) { if(showcarddif >= CARD_IMG_WIDTH) {
showcard = 0; showcard = 0;
...@@ -944,12 +944,13 @@ void Game::DrawSpec() { ...@@ -944,12 +944,13 @@ void Game::DrawSpec() {
showChat = false; showChat = false;
hideChatTimer--; hideChatTimer--;
} }
int maxChatLines = mainGame->dInfo.isStarted ? 5 : 8; for(int i = 0; i < 8; ++i) {
for(int i = 0; i < maxChatLines; ++i) {
static unsigned int chatColor[] = {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xff8080ff, 0xffff4040, 0xffff4040, static unsigned int chatColor[] = {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xff8080ff, 0xffff4040, 0xffff4040,
0xffff4040, 0xff40ff40, 0xff4040ff, 0xff40ffff, 0xffff40ff, 0xffffff40, 0xffffffff, 0xff808080, 0xff404040}; 0xffff4040, 0xff40ff40, 0xff4040ff, 0xff40ffff, 0xffff40ff, 0xffffff40, 0xffffffff, 0xff808080, 0xff404040};
if(chatTiming[i]) { if(chatTiming[i]) {
chatTiming[i]--; chatTiming[i]--;
if(mainGame->dInfo.isStarted && i >= 5)
continue;
if(!showChat && i > 2) if(!showChat && i > 2)
continue; continue;
int w = textFont->getDimension(chatMsg[i].c_str()).Width; int w = textFont->getDimension(chatMsg[i].c_str()).Width;
...@@ -968,7 +969,7 @@ void Game::ShowElement(irr::gui::IGUIElement * win, int autoframe) { ...@@ -968,7 +969,7 @@ void Game::ShowElement(irr::gui::IGUIElement * win, int autoframe) {
FadingUnit fu; FadingUnit fu;
fu.fadingSize = win->getRelativePosition(); fu.fadingSize = win->getRelativePosition();
for(auto fit = fadingList.begin(); fit != fadingList.end(); ++fit) for(auto fit = fadingList.begin(); fit != fadingList.end(); ++fit)
if(win == fit->guiFading) if(win == fit->guiFading && win != wOptions) // the size of wOptions is always setted by ClientField::ShowSelectOption before showing it
fu.fadingSize = fit->fadingSize; fu.fadingSize = fit->fadingSize;
irr::core::position2di center = fu.fadingSize.getCenter(); irr::core::position2di center = fu.fadingSize.getCenter();
fu.fadingDiff.X = fu.fadingSize.getWidth() / 10; fu.fadingDiff.X = fu.fadingSize.getWidth() / 10;
...@@ -1043,7 +1044,7 @@ void Game::PopupElement(irr::gui::IGUIElement * element, int hideframe) { ...@@ -1043,7 +1044,7 @@ void Game::PopupElement(irr::gui::IGUIElement * element, int hideframe) {
} }
void Game::WaitFrameSignal(int frame) { void Game::WaitFrameSignal(int frame) {
frameSignal.Reset(); frameSignal.Reset();
signalFrame = frame; signalFrame = (gameConf.quick_animation && frame >= 12) ? 12 : frame;
frameSignal.Wait(); frameSignal.Wait();
} }
void Game::DrawThumb(code_pointer cp, position2di pos, std::unordered_map<int, int>* lflist) { void Game::DrawThumb(code_pointer cp, position2di pos, std::unordered_map<int, int>* lflist) {
...@@ -1168,7 +1169,7 @@ void Game::DrawDeckBd() { ...@@ -1168,7 +1169,7 @@ void Game::DrawDeckBd() {
textFont->draw(textBuffer, recti(859, 164 + i * 66, 955, 185 + i * 66), 0xff000000, false, false); textFont->draw(textBuffer, recti(859, 164 + i * 66, 955, 185 + i * 66), 0xff000000, false, false);
textFont->draw(textBuffer, recti(860, 165 + i * 66, 955, 185 + i * 66), 0xffffffff, false, false); textFont->draw(textBuffer, recti(860, 165 + i * 66, 955, 185 + i * 66), 0xffffffff, false, false);
if(!(ptr->second.type & TYPE_LINK)) { if(!(ptr->second.type & TYPE_LINK)) {
wchar_t* form = L"\u2605"; const wchar_t* form = L"\u2605";
if(ptr->second.type & TYPE_XYZ) form = L"\u2606"; if(ptr->second.type & TYPE_XYZ) form = L"\u2606";
myswprintf(textBuffer, L"%ls/%ls %ls%d", dataManager.FormatAttribute(ptr->second.attribute), dataManager.FormatRace(ptr->second.race), form, ptr->second.level); myswprintf(textBuffer, L"%ls/%ls %ls%d", dataManager.FormatAttribute(ptr->second.attribute), dataManager.FormatRace(ptr->second.race), form, ptr->second.level);
textFont->draw(textBuffer, recti(859, 186 + i * 66, 955, 207 + i * 66), 0xff000000, false, false); textFont->draw(textBuffer, recti(859, 186 + i * 66, 955, 207 + i * 66), 0xff000000, false, false);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -39,9 +39,12 @@ struct Config { ...@@ -39,9 +39,12 @@ struct Config {
int draw_field_spell; int draw_field_spell;
int separate_clear_button; int separate_clear_button;
int auto_search_limit; int auto_search_limit;
int search_multiple_keywords;
int chkIgnoreDeckChanges; int chkIgnoreDeckChanges;
int defaultOT; int defaultOT;
int enable_bot_mode; int enable_bot_mode;
int quick_animation;
int auto_save_replay;
bool enable_sound; bool enable_sound;
bool enable_music; bool enable_music;
double sound_volume; double sound_volume;
...@@ -130,8 +133,11 @@ public: ...@@ -130,8 +133,11 @@ public:
void LoadConfig(); void LoadConfig();
void SaveConfig(); void SaveConfig();
void ShowCardInfo(int code); void ShowCardInfo(int code);
void AddChatMsg(wchar_t* msg, int player); void ClearCardInfo(int player = 0);
void AddDebugMsg(char* msgbuf); void AddChatMsg(const wchar_t* msg, int player);
void ClearChatMsg();
void AddDebugMsg(const char* msgbuf);
void ErrorLog(const char* msgbuf);
void ClearTextures(); void ClearTextures();
void CloseDuelWindow(); void CloseDuelWindow();
...@@ -220,6 +226,7 @@ public: ...@@ -220,6 +226,7 @@ public:
//hint text //hint text
irr::gui::IGUIStaticText* stHintMsg; irr::gui::IGUIStaticText* stHintMsg;
irr::gui::IGUIStaticText* stTip; irr::gui::IGUIStaticText* stTip;
irr::gui::IGUIStaticText* stCardListTip;
//infos //infos
irr::gui::IGUITabControl* wInfos; irr::gui::IGUITabControl* wInfos;
irr::gui::IGUIStaticText* stName; irr::gui::IGUIStaticText* stName;
...@@ -236,10 +243,13 @@ public: ...@@ -236,10 +243,13 @@ public:
irr::gui::IGUICheckBox* chkRandomPos; irr::gui::IGUICheckBox* chkRandomPos;
irr::gui::IGUICheckBox* chkAutoChain; irr::gui::IGUICheckBox* chkAutoChain;
irr::gui::IGUICheckBox* chkWaitChain; irr::gui::IGUICheckBox* chkWaitChain;
irr::gui::IGUICheckBox* chkQuickAnimation;
irr::gui::IGUICheckBox* chkAutoSaveReplay;
irr::gui::IGUICheckBox* chkHideSetname; irr::gui::IGUICheckBox* chkHideSetname;
irr::gui::IGUICheckBox* chkHideHintButton; irr::gui::IGUICheckBox* chkHideHintButton;
irr::gui::IGUICheckBox* chkIgnoreDeckChanges; irr::gui::IGUICheckBox* chkIgnoreDeckChanges;
irr::gui::IGUICheckBox* chkAutoSearch; irr::gui::IGUICheckBox* chkAutoSearch;
irr::gui::IGUICheckBox* chkMultiKeywords;
irr::gui::IGUICheckBox* chkEnableSound; irr::gui::IGUICheckBox* chkEnableSound;
irr::gui::IGUICheckBox* chkEnableMusic; irr::gui::IGUICheckBox* chkEnableMusic;
irr::gui::IGUIScrollBar* scrSoundVolume; irr::gui::IGUIScrollBar* scrSoundVolume;
...@@ -342,6 +352,7 @@ public: ...@@ -342,6 +352,7 @@ public:
irr::gui::IGUIButton* btnOptionp; irr::gui::IGUIButton* btnOptionp;
irr::gui::IGUIButton* btnOptionn; irr::gui::IGUIButton* btnOptionn;
irr::gui::IGUIButton* btnOptionOK; irr::gui::IGUIButton* btnOptionOK;
irr::gui::IGUIButton* btnOption[5];
//pos selection //pos selection
irr::gui::IGUIWindow* wPosSelect; irr::gui::IGUIWindow* wPosSelect;
irr::gui::CGUIImageButton* btnPSAU; irr::gui::CGUIImageButton* btnPSAU;
...@@ -539,6 +550,11 @@ extern Game* mainGame; ...@@ -539,6 +550,11 @@ extern Game* mainGame;
#define BUTTON_OPTION_PREV 220 #define BUTTON_OPTION_PREV 220
#define BUTTON_OPTION_NEXT 221 #define BUTTON_OPTION_NEXT 221
#define BUTTON_OPTION_OK 222 #define BUTTON_OPTION_OK 222
#define BUTTON_OPTION_0 223
#define BUTTON_OPTION_1 224
#define BUTTON_OPTION_2 225
#define BUTTON_OPTION_3 226
#define BUTTON_OPTION_4 227
#define BUTTON_CARD_0 230 #define BUTTON_CARD_0 230
#define BUTTON_CARD_1 231 #define BUTTON_CARD_1 231
#define BUTTON_CARD_2 232 #define BUTTON_CARD_2 232
...@@ -546,6 +562,7 @@ extern Game* mainGame; ...@@ -546,6 +562,7 @@ extern Game* mainGame;
#define BUTTON_CARD_4 234 #define BUTTON_CARD_4 234
#define SCROLL_CARD_SELECT 235 #define SCROLL_CARD_SELECT 235
#define BUTTON_CARD_SEL_OK 236 #define BUTTON_CARD_SEL_OK 236
#define TEXT_CARD_LIST_TIP 237
#define BUTTON_CMD_ACTIVATE 240 #define BUTTON_CMD_ACTIVATE 240
#define BUTTON_CMD_SUMMON 241 #define BUTTON_CMD_SUMMON 241
#define BUTTON_CMD_SPSUMMON 242 #define BUTTON_CMD_SPSUMMON 242
...@@ -616,9 +633,12 @@ extern Game* mainGame; ...@@ -616,9 +633,12 @@ extern Game* mainGame;
#define BUTTON_LOAD_SINGLEPLAY 351 #define BUTTON_LOAD_SINGLEPLAY 351
#define BUTTON_CANCEL_SINGLEPLAY 352 #define BUTTON_CANCEL_SINGLEPLAY 352
#define CHECKBOX_AUTO_SEARCH 360 #define CHECKBOX_AUTO_SEARCH 360
#define CHECKBOX_MULTI_KEYWORDS 372
#define CHECKBOX_ENABLE_SOUND 361 #define CHECKBOX_ENABLE_SOUND 361
#define CHECKBOX_ENABLE_MUSIC 362 #define CHECKBOX_ENABLE_MUSIC 362
#define SCROLL_VOLUME 363 #define SCROLL_VOLUME 363
#define CHECKBOX_DISABLE_CHAT 364
#define CHECKBOX_QUICK_ANIMATION 369
#define COMBOBOX_SORTTYPE 370 #define COMBOBOX_SORTTYPE 370
#define COMBOBOX_LIMIT 371 #define COMBOBOX_LIMIT 371
...@@ -631,4 +651,6 @@ extern Game* mainGame; ...@@ -631,4 +651,6 @@ extern Game* mainGame;
#define BUTTON_RENAME_DECK_CANCEL 388 #define BUTTON_RENAME_DECK_CANCEL 388
#define DEFAULT_DUEL_RULE 4 #define DEFAULT_DUEL_RULE 4
#define CARD_ARTWORK_VERSIONS_OFFSET 10
#endif // GAME_H #endif // GAME_H
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include "game.h" #include "game.h"
#include "data_manager.h" #include "data_manager.h"
#include <event2/thread.h> #include <event2/thread.h>
#include <memory>
#ifdef __APPLE__ #ifdef __APPLE__
#import <CoreFoundation/CoreFoundation.h> #import <CoreFoundation/CoreFoundation.h>
#endif #endif
...@@ -12,22 +13,6 @@ bool open_file = false; ...@@ -12,22 +13,6 @@ bool open_file = false;
wchar_t open_file_name[256] = L""; wchar_t open_file_name[256] = L"";
bool bot_mode = false; bool bot_mode = false;
void GetParameter(char* param, const char* arg) {
#ifdef _WIN32
wchar_t arg1[260];
MultiByteToWideChar(CP_ACP, 0, arg, -1, arg1, 260);
BufferIO::EncodeUTF8(arg1, param);
#else
strcpy(param, arg);
#endif
}
void GetParameterW(wchar_t* param, const char* arg) {
#ifdef _WIN32
MultiByteToWideChar(CP_ACP, 0, arg, -1, param, 260);
#else
BufferIO::DecodeUTF8(arg, param);
#endif
}
void ClickButton(irr::gui::IGUIElement* btn) { void ClickButton(irr::gui::IGUIElement* btn) {
irr::SEvent event; irr::SEvent event;
event.EventType = irr::EET_GUI_EVENT; event.EventType = irr::EET_GUI_EVENT;
...@@ -51,11 +36,15 @@ int main(int argc, char* argv[]) { ...@@ -51,11 +36,15 @@ int main(int argc, char* argv[]) {
#endif //__APPLE__ #endif //__APPLE__
#ifdef _WIN32 #ifdef _WIN32
#ifndef _DEBUG #ifndef _DEBUG
wchar_t exepath[MAX_PATH]; char* pstrext;
GetModuleFileNameW(NULL, exepath, MAX_PATH); if(argc == 2 && (pstrext = strrchr(argv[1], '.'))
wchar_t* p = wcsrchr(exepath, '\\'); && (!mystrncasecmp(pstrext, ".ydk", 4) || !mystrncasecmp(pstrext, ".yrp", 4))) {
*p = '\0'; wchar_t exepath[MAX_PATH];
SetCurrentDirectoryW(exepath); GetModuleFileNameW(NULL, exepath, MAX_PATH);
wchar_t* p = wcsrchr(exepath, '\\');
*p = '\0';
SetCurrentDirectoryW(exepath);
}
#endif //_DEBUG #endif //_DEBUG
#endif //_WIN32 #endif //_WIN32
#ifdef _WIN32 #ifdef _WIN32
...@@ -72,103 +61,116 @@ int main(int argc, char* argv[]) { ...@@ -72,103 +61,116 @@ int main(int argc, char* argv[]) {
if(!ygo::mainGame->Initialize()) if(!ygo::mainGame->Initialize())
return 0; return 0;
#ifdef _WIN32
int wargc;
std::unique_ptr<wchar_t*[], void(*)(wchar_t**)> wargv(CommandLineToArgvW(GetCommandLineW(), &wargc), [](wchar_t** wargv) {
LocalFree(wargv);
});
#else
int wargc = argc;
auto wargv = std::make_unique<wchar_t[][256]>(wargc);
for(int i = 0; i < argc; ++i) {
BufferIO::DecodeUTF8(argv[i], wargv[i]);
}
#endif //_WIN32
bool keep_on_return = false; bool keep_on_return = false;
for(int i = 1; i < argc; ++i) { for(int i = 1; i < wargc; ++i) {
if(argv[i][0] == '-' && argv[i][1] == 'e') { if(wargv[i][0] == L'-' && wargv[i][1] == L'e' && wargv[i][2] != L'\0') {
char param[128]; char param[128];
GetParameter(param, &argv[i][2]); BufferIO::EncodeUTF8(&wargv[i][2], param);
ygo::dataManager.LoadDB(param); ygo::dataManager.LoadDB(param);
continue; continue;
} }
if(!strcmp(argv[i], "-e")) { // extra database if(!wcscmp(wargv[i], L"-e")) { // extra database
++i; ++i;
char param[128]; if(i < wargc) {
GetParameter(param, &argv[i][0]); char param[128];
ygo::dataManager.LoadDB(param); BufferIO::EncodeUTF8(wargv[i], param);
ygo::dataManager.LoadDB(param);
}
continue; continue;
} else if(!strcmp(argv[i], "-n")) { // nickName } else if(!wcscmp(wargv[i], L"-n")) { // nickName
++i; ++i;
wchar_t param[128]; if(i < wargc)
GetParameterW(param, &argv[i][0]); ygo::mainGame->ebNickName->setText(wargv[i]);
ygo::mainGame->ebNickName->setText(param);
continue; continue;
} else if(!strcmp(argv[i], "-h")) { // Host address } else if(!wcscmp(wargv[i], L"-h")) { // Host address
++i; ++i;
wchar_t param[128]; if(i < wargc)
GetParameterW(param, &argv[i][0]); ygo::mainGame->ebJoinHost->setText(wargv[i]);
ygo::mainGame->ebJoinHost->setText(param);
continue; continue;
} else if(!strcmp(argv[i], "-p")) { // host Port } else if(!wcscmp(wargv[i], L"-p")) { // host Port
++i; ++i;
wchar_t param[128]; if(i < wargc)
GetParameterW(param, &argv[i][0]); ygo::mainGame->ebJoinPort->setText(wargv[i]);
ygo::mainGame->ebJoinPort->setText(param);
continue; continue;
} else if(!strcmp(argv[i], "-w")) { // host passWord } else if(!wcscmp(wargv[i], L"-w")) { // host passWord
++i; ++i;
wchar_t param[128]; if(i < wargc)
GetParameterW(param, &argv[i][0]); ygo::mainGame->ebJoinPass->setText(wargv[i]);
ygo::mainGame->ebJoinPass->setText(param);
continue; continue;
} else if(!strcmp(argv[i], "-k")) { // Keep on return } else if(!wcscmp(wargv[i], L"-k")) { // Keep on return
exit_on_return = false; exit_on_return = false;
keep_on_return = true; keep_on_return = true;
} else if(!strcmp(argv[i], "-d")) { // Deck } else if(!wcscmp(wargv[i], L"-d")) { // Deck
if(i + 2 < argc) { // select deck ++i;
++i; if(i + 1 < wargc) { // select deck
GetParameterW(ygo::mainGame->gameConf.lastdeck, &argv[i][0]); wcscpy(ygo::mainGame->gameConf.lastdeck, wargv[i]);
continue; continue;
} else { // open deck } else { // open deck
exit_on_return = !keep_on_return; exit_on_return = !keep_on_return;
if(i < argc) { if(i < wargc) {
open_file = true; open_file = true;
GetParameterW(open_file_name, &argv[i + 1][0]); wcscpy(open_file_name, wargv[i]);
} }
ClickButton(ygo::mainGame->btnDeckEdit); ClickButton(ygo::mainGame->btnDeckEdit);
break; break;
} }
} else if(!strcmp(argv[i], "-c")) { // Create host } else if(!wcscmp(wargv[i], L"-c")) { // Create host
exit_on_return = !keep_on_return; exit_on_return = !keep_on_return;
ygo::mainGame->HideElement(ygo::mainGame->wMainMenu); ygo::mainGame->HideElement(ygo::mainGame->wMainMenu);
ClickButton(ygo::mainGame->btnHostConfirm); ClickButton(ygo::mainGame->btnHostConfirm);
break; break;
} else if(!strcmp(argv[i], "-j")) { // Join host } else if(!wcscmp(wargv[i], L"-j")) { // Join host
exit_on_return = !keep_on_return; exit_on_return = !keep_on_return;
ClickButton(ygo::mainGame->btnLanMode); ygo::mainGame->HideElement(ygo::mainGame->wMainMenu);
ClickButton(ygo::mainGame->btnJoinHost); ClickButton(ygo::mainGame->btnJoinHost);
break; break;
} else if(!strcmp(argv[i], "-r")) { // Replay } else if(!wcscmp(wargv[i], L"-r")) { // Replay
exit_on_return = !keep_on_return; exit_on_return = !keep_on_return;
if(i < argc) { ++i;
if(i < wargc) {
open_file = true; open_file = true;
GetParameterW(open_file_name, &argv[i + 1][0]); wcscpy(open_file_name, wargv[i]);
} }
ClickButton(ygo::mainGame->btnReplayMode); ClickButton(ygo::mainGame->btnReplayMode);
if(open_file) if(open_file)
ClickButton(ygo::mainGame->btnLoadReplay); ClickButton(ygo::mainGame->btnLoadReplay);
break; break;
} else if(!strcmp(argv[i], "-s")) { // Single } else if(!wcscmp(wargv[i], L"-s")) { // Single
exit_on_return = !keep_on_return; exit_on_return = !keep_on_return;
if(i < argc) { ++i;
if(i < wargc) {
open_file = true; open_file = true;
GetParameterW(open_file_name, &argv[i + 1][0]); wcscpy(open_file_name, wargv[i]);
} }
ClickButton(ygo::mainGame->btnSingleMode); ClickButton(ygo::mainGame->btnSingleMode);
if(open_file) if(open_file)
ClickButton(ygo::mainGame->btnLoadSinglePlay); ClickButton(ygo::mainGame->btnLoadSinglePlay);
break; break;
} else if(argc == 2 && strlen(argv[1]) >= 4) { } else if(wargc == 2 && wcslen(wargv[1]) >= 4) {
char* pstrext = argv[1] + strlen(argv[1]) - 4; wchar_t* pstrext = wargv[1] + wcslen(wargv[1]) - 4;
if(!mystrncasecmp(pstrext, ".ydk", 4)) { if(!mywcsncasecmp(pstrext, L".ydk", 4)) {
open_file = true; open_file = true;
GetParameterW(open_file_name, &argv[1][0]); wcscpy(open_file_name, wargv[i]);
exit_on_return = !keep_on_return; exit_on_return = !keep_on_return;
ClickButton(ygo::mainGame->btnDeckEdit); ClickButton(ygo::mainGame->btnDeckEdit);
break; break;
} }
if(!mystrncasecmp(pstrext, ".yrp", 4)) { if(!mywcsncasecmp(pstrext, L".yrp", 4)) {
open_file = true; open_file = true;
GetParameterW(open_file_name, &argv[1][0]); wcscpy(open_file_name, wargv[i]);
exit_on_return = !keep_on_return; exit_on_return = !keep_on_return;
ClickButton(ygo::mainGame->btnReplayMode); ClickButton(ygo::mainGame->btnReplayMode);
ClickButton(ygo::mainGame->btnLoadReplay); ClickButton(ygo::mainGame->btnLoadReplay);
......
project (clzma)
set (AUTO_FILES_RESULT)
AutoFiles("." "src" "\\.(cpp|c|h)$")
add_library (clzma STATIC ${AUTO_FILES_RESULT})
...@@ -27,6 +27,8 @@ void UpdateDeck() { ...@@ -27,6 +27,8 @@ void UpdateDeck() {
DuelClient::SendBufferToServer(CTOS_UPDATE_DECK, deckbuf, pdeck - deckbuf); DuelClient::SendBufferToServer(CTOS_UPDATE_DECK, deckbuf, pdeck - deckbuf);
} }
bool MenuHandler::OnEvent(const irr::SEvent& event) { bool MenuHandler::OnEvent(const irr::SEvent& event) {
if(mainGame->dField.OnCommonEvent(event))
return false;
switch(event.EventType) { switch(event.EventType) {
case irr::EET_GUI_EVENT: { case irr::EET_GUI_EVENT: {
irr::gui::IGUIElement* caller = event.GUIEvent.Caller; irr::gui::IGUIElement* caller = event.GUIEvent.Caller;
...@@ -40,16 +42,6 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -40,16 +42,6 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break; break;
} }
switch(event.GUIEvent.EventType) { switch(event.GUIEvent.EventType) {
case irr::gui::EGET_ELEMENT_HOVERED: {
if(event.GUIEvent.Caller->getType() == EGUIET_EDIT_BOX)
mainGame->SetCursor(event.GUIEvent.Caller->isEnabled() ? ECI_IBEAM : ECI_NORMAL);
break;
}
case irr::gui::EGET_ELEMENT_LEFT: {
if(event.GUIEvent.Caller->getType() == EGUIET_EDIT_BOX)
mainGame->SetCursor(ECI_NORMAL);
break;
}
case irr::gui::EGET_BUTTON_CLICKED: { case irr::gui::EGET_BUTTON_CLICKED: {
if(id < 110) if(id < 110)
soundManager.PlaySoundEffect(SOUND_MENU); soundManager.PlaySoundEffect(SOUND_MENU);
...@@ -230,16 +222,10 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -230,16 +222,10 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
if(!ReplayMode::cur_replay.OpenReplay(mainGame->lstReplayList->getListItem(mainGame->lstReplayList->getSelected()))) if(!ReplayMode::cur_replay.OpenReplay(mainGame->lstReplayList->getListItem(mainGame->lstReplayList->getSelected())))
break; break;
} }
mainGame->imgCard->setImage(imageManager.tCover[0]); mainGame->ClearCardInfo();
mainGame->wCardImg->setVisible(true); mainGame->wCardImg->setVisible(true);
mainGame->wInfos->setVisible(true); mainGame->wInfos->setVisible(true);
mainGame->wReplay->setVisible(true); mainGame->wReplay->setVisible(true);
mainGame->stName->setText(L"");
mainGame->stInfo->setText(L"");
mainGame->stDataInfo->setText(L"");
mainGame->stSetName->setText(L"");
mainGame->stText->setText(L"");
mainGame->scrCardText->setVisible(false);
mainGame->wReplayControl->setVisible(true); mainGame->wReplayControl->setVisible(true);
mainGame->btnReplayStart->setVisible(false); mainGame->btnReplayStart->setVisible(false);
mainGame->btnReplayPause->setVisible(true); mainGame->btnReplayPause->setVisible(true);
...@@ -453,7 +439,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -453,7 +439,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
std::wstring repinfo; std::wstring repinfo;
time_t curtime = ReplayMode::cur_replay.pheader.seed; time_t curtime = ReplayMode::cur_replay.pheader.seed;
tm* st = localtime(&curtime); tm* st = localtime(&curtime);
myswprintf(infobuf, L"%d/%d/%d %02d:%02d:%02d\n", st->tm_year + 1900, st->tm_mon + 1, st->tm_mday, st->tm_hour, st->tm_min, st->tm_sec); wcsftime(infobuf, 256, L"%Y/%m/%d %H:%M:%S\n", st);
repinfo.append(infobuf); repinfo.append(infobuf);
wchar_t namebuf[4][20]; wchar_t namebuf[4][20];
ReplayMode::cur_replay.ReadName(namebuf[0]); ReplayMode::cur_replay.ReadName(namebuf[0]);
...@@ -468,7 +454,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -468,7 +454,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
myswprintf(infobuf, L"%ls\n===VS===\n%ls\n", namebuf[0], namebuf[1]); myswprintf(infobuf, L"%ls\n===VS===\n%ls\n", namebuf[0], namebuf[1]);
repinfo.append(infobuf); repinfo.append(infobuf);
mainGame->ebRepStartTurn->setText(L"1"); mainGame->ebRepStartTurn->setText(L"1");
mainGame->SetStaticText(mainGame->stReplayInfo, 180, mainGame->guiFont, (wchar_t*)repinfo.c_str()); mainGame->SetStaticText(mainGame->stReplayInfo, 180, mainGame->guiFont, repinfo.c_str());
break; break;
} }
case LISTBOX_BOT_LIST: { case LISTBOX_BOT_LIST: {
...@@ -509,49 +495,6 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -509,49 +495,6 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
} }
break; break;
} }
case irr::gui::EGET_EDITBOX_ENTER: {
switch(id) {
case EDITBOX_CHAT: {
if(mainGame->dInfo.isReplay)
break;
const wchar_t* input = mainGame->ebChatInput->getText();
if(input[0]) {
unsigned short msgbuf[256];
if(mainGame->dInfo.isStarted) {
if(mainGame->dInfo.player_type < 7) {
if(mainGame->dInfo.isTag && (mainGame->dInfo.player_type % 2))
mainGame->AddChatMsg((wchar_t*)input, 2);
else
mainGame->AddChatMsg((wchar_t*)input, 0);
} else
mainGame->AddChatMsg((wchar_t*)input, 10);
} else
mainGame->AddChatMsg((wchar_t*)input, 7);
int len = BufferIO::CopyWStr(input, msgbuf, 256);
DuelClient::SendBufferToServer(CTOS_CHAT, msgbuf, (len + 1) * sizeof(short));
mainGame->ebChatInput->setText(L"");
}
break;
}
}
break;
}
default: break;
}
break;
}
case irr::EET_KEY_INPUT_EVENT: {
switch(event.KeyInput.Key) {
case irr::KEY_KEY_R: {
if(!event.KeyInput.PressedDown && !mainGame->HasFocus(EGUIET_EDIT_BOX))
mainGame->textFont->setTransparency(true);
break;
}
case irr::KEY_ESCAPE: {
if(!mainGame->HasFocus(EGUIET_EDIT_BOX))
mainGame->device->minimizeWindow();
break;
}
default: break; default: break;
} }
break; break;
......
#ifndef FILESYSTEM_H
#define FILESYSTEM_H
#include <string.h>
#include <functional>
#include "bufferio.h"
#ifdef _WIN32
#include <direct.h>
#include <sys/stat.h>
#else
#include <dirent.h>
#include <sys/stat.h>
#endif
#ifdef _WIN32
#include <Windows.h>
class FileSystem {
public:
static bool IsFileExists(const wchar_t* wfile) {
struct _stat fileStat;
return (_wstat(wfile, &fileStat) == 0) && !(fileStat.st_mode & _S_IFDIR);
}
static bool IsFileExists(const char* file) {
wchar_t wfile[1024];
BufferIO::DecodeUTF8(file, wfile);
return IsFileExists(wfile);
}
static bool IsDirExists(const wchar_t* wdir) {
struct _stat fileStat;
return (_wstat(wdir, &fileStat) == 0) && (fileStat.st_mode & _S_IFDIR);
}
static bool IsDirExists(const char* dir) {
wchar_t wdir[1024];
BufferIO::DecodeUTF8(dir, wdir);
return IsDirExists(wdir);
}
static bool MakeDir(const wchar_t* wdir) {
return _wmkdir(wdir) == 0;
}
static bool MakeDir(const char* dir) {
wchar_t wdir[1024];
BufferIO::DecodeUTF8(dir, wdir);
return MakeDir(wdir);
}
static void TraversalDir(const wchar_t* wpath, const std::function<void(const wchar_t*, bool)>& cb) {
wchar_t findstr[1024];
wcscpy(findstr, wpath);
wcscat(findstr, L"/*");
WIN32_FIND_DATAW fdataw;
HANDLE fh = FindFirstFileW(findstr, &fdataw);
if(fh == INVALID_HANDLE_VALUE)
return;
do {
cb(fdataw.cFileName, (fdataw.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY));
} while(FindNextFileW(fh, &fdataw));
FindClose(fh);
}
static void TraversalDir(const char* path, const std::function<void(const char*, bool)>& cb) {
wchar_t wpath[1024];
BufferIO::DecodeUTF8(path, wpath);
TraversalDir(wpath, [&cb](const wchar_t* wname, bool isdir) {
char name[1024];
BufferIO::EncodeUTF8(wname, name);
cb(name, isdir);
});
}
};
#else
class FileSystem {
public:
static bool IsFileExists(const char* file) {
struct stat fileStat;
return (stat(file, &fileStat) == 0) && !S_ISDIR(fileStat.st_mode);
}
static bool IsFileExists(const wchar_t* wfile) {
char file[1024];
BufferIO::EncodeUTF8(wfile, file);
return IsFileExists(file);
}
static bool IsDirExists(const char* dir) {
struct stat fileStat;
return (stat(dir, &fileStat) == 0) && S_ISDIR(fileStat.st_mode);
}
static bool IsDirExists(const wchar_t* wdir) {
char dir[1024];
BufferIO::EncodeUTF8(wdir, dir);
return IsDirExists(dir);
}
static bool MakeDir(const char* dir) {
return mkdir(dir, 0775) == 0;
}
static bool MakeDir(const wchar_t* wdir) {
char dir[1024];
BufferIO::EncodeUTF8(wdir, dir);
return MakeDir(dir);
}
static void TraversalDir(const char* path, const std::function<void(const char*, bool)>& cb) {
DIR* dir = nullptr;
struct dirent* dirp = nullptr;
if((dir = opendir(path)) == nullptr)
return;
struct stat fileStat;
while((dirp = readdir(dir)) != nullptr) {
char fname[1024];
strcpy(fname, path);
strcat(fname, "/");
strcat(fname, dirp->d_name);
stat(fname, &fileStat);
cb(dirp->d_name, S_ISDIR(fileStat.st_mode));
}
closedir(dir);
}
static void TraversalDir(const wchar_t* wpath, const std::function<void(const wchar_t*, bool)>& cb) {
char path[1024];
BufferIO::EncodeUTF8(wpath, path);
TraversalDir(path, [&cb](const char* name, bool isdir) {
wchar_t wname[1024];
BufferIO::DecodeUTF8(name, wname);
cb(wname, isdir);
});
}
};
#endif // _WIN32
#endif //FILESYSTEM_H
...@@ -26,9 +26,9 @@ project "ygopro" ...@@ -26,9 +26,9 @@ project "ygopro"
configuration {"windows", "not vs*"} configuration {"windows", "not vs*"}
includedirs { "/mingw/include/irrlicht", "/mingw/include/freetype2" } includedirs { "/mingw/include/irrlicht", "/mingw/include/freetype2" }
configuration "not vs*" configuration "not vs*"
buildoptions { "-std=gnu++0x", "-fno-rtti" } buildoptions { "-std=c++14", "-fno-rtti" }
configuration "not windows" configuration "not windows"
includedirs { "/usr/include/lua", "/usr/include/lua5.3", "/usr/include/lua/5.3", "/usr/include/irrlicht", "/usr/include/freetype2" } includedirs { "/usr/include/irrlicht", "/usr/include/freetype2" }
excludes { "COSOperator.*" } excludes { "COSOperator.*" }
links { "event_pthreads", "GL", "dl", "pthread" } links { "event_pthreads", "GL", "dl", "pthread" }
configuration "linux" configuration "linux"
......
#include "replay.h" #include "replay.h"
#include "../ocgcore/ocgapi.h" #include "../ocgcore/ocgapi.h"
#include "../ocgcore/card.h" #include "../ocgcore/common.h"
#include <algorithm> #include <algorithm>
#include "lzma/LzmaLib.h" #include "lzma/LzmaLib.h"
...@@ -17,6 +17,8 @@ Replay::~Replay() { ...@@ -17,6 +17,8 @@ Replay::~Replay() {
delete[] comp_data; delete[] comp_data;
} }
void Replay::BeginRecord() { void Replay::BeginRecord() {
if(!FileSystem::IsDirExists(L"./replay") && !FileSystem::MakeDir(L"./replay"))
return;
#ifdef _WIN32 #ifdef _WIN32
if(is_recording) if(is_recording)
CloseHandle(recording_fp); CloseHandle(recording_fp);
...@@ -123,6 +125,8 @@ void Replay::EndRecord() { ...@@ -123,6 +125,8 @@ void Replay::EndRecord() {
is_recording = false; is_recording = false;
} }
void Replay::SaveReplay(const wchar_t* name) { void Replay::SaveReplay(const wchar_t* name) {
if(!FileSystem::IsDirExists(L"./replay") && !FileSystem::MakeDir(L"./replay"))
return;
wchar_t fname[256]; wchar_t fname[256];
myswprintf(fname, L"./replay/%ls.yrp", name); myswprintf(fname, L"./replay/%ls.yrp", name);
#ifdef WIN32 #ifdef WIN32
...@@ -159,7 +163,10 @@ bool Replay::OpenReplay(const wchar_t* name) { ...@@ -159,7 +163,10 @@ bool Replay::OpenReplay(const wchar_t* name) {
} }
if(!fp) if(!fp)
return false; return false;
fread(&pheader, sizeof(pheader), 1, fp); if(fread(&pheader, sizeof(pheader), 1, fp) < 1) {
fclose(fp);
return false;
}
if(pheader.flag & REPLAY_COMPRESSED) { if(pheader.flag & REPLAY_COMPRESSED) {
comp_size = fread(comp_data, 1, 0x1000, fp); comp_size = fread(comp_data, 1, 0x1000, fp);
fclose(fp); fclose(fp);
...@@ -188,9 +195,9 @@ bool Replay::CheckReplay(const wchar_t* name) { ...@@ -188,9 +195,9 @@ bool Replay::CheckReplay(const wchar_t* name) {
if(!rfp) if(!rfp)
return false; return false;
ReplayHeader rheader; ReplayHeader rheader;
fread(&rheader, sizeof(ReplayHeader), 1, rfp); size_t count = fread(&rheader, sizeof(ReplayHeader), 1, rfp);
fclose(rfp); fclose(rfp);
return rheader.id == 0x31707279 && rheader.version >= 0x12d0; return count == 1 && rheader.id == 0x31707279 && rheader.version >= 0x12d0;
} }
bool Replay::DeleteReplay(const wchar_t* name) { bool Replay::DeleteReplay(const wchar_t* name) {
wchar_t fname[256]; wchar_t fname[256];
......
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
#include "duelclient.h" #include "duelclient.h"
#include "game.h" #include "game.h"
#include "single_mode.h" #include "single_mode.h"
#include "../ocgcore/duel.h" #include "../ocgcore/common.h"
#include "../ocgcore/field.h"
#include "../ocgcore/mtrandom.h" #include "../ocgcore/mtrandom.h"
namespace ygo { namespace ygo {
...@@ -65,11 +64,11 @@ int ReplayMode::ReplayThread(void* param) { ...@@ -65,11 +64,11 @@ int ReplayMode::ReplayThread(void* param) {
mainGame->dInfo.tag_player[0] = false; mainGame->dInfo.tag_player[0] = false;
mainGame->dInfo.tag_player[1] = false; mainGame->dInfo.tag_player[1] = false;
if(mainGame->dInfo.isSingleMode) { if(mainGame->dInfo.isSingleMode) {
set_script_reader((script_reader)SingleMode::ScriptReader); set_script_reader((script_reader)SingleMode::ScriptReaderEx);
set_card_reader((card_reader)DataManager::CardReader); set_card_reader((card_reader)DataManager::CardReader);
set_message_handler((message_handler)MessageHandler); set_message_handler((message_handler)MessageHandler);
} else { } else {
set_script_reader(default_script_reader); set_script_reader((script_reader)ScriptReaderEx);
set_card_reader((card_reader)DataManager::CardReader); set_card_reader((card_reader)DataManager::CardReader);
set_message_handler((message_handler)MessageHandler); set_message_handler((message_handler)MessageHandler);
} }
...@@ -106,6 +105,7 @@ int ReplayMode::ReplayThread(void* param) { ...@@ -106,6 +105,7 @@ int ReplayMode::ReplayThread(void* param) {
get_message(pduel, (byte*)engineBuffer); get_message(pduel, (byte*)engineBuffer);
is_continuing = ReplayAnalyze(engineBuffer, len); is_continuing = ReplayAnalyze(engineBuffer, len);
if(is_restarting) { if(is_restarting) {
mainGame->gMutex.Lock();
is_restarting = false; is_restarting = false;
int step = current_step - 1; int step = current_step - 1;
if(step < 0) if(step < 0)
...@@ -218,7 +218,7 @@ bool ReplayMode::StartDuel() { ...@@ -218,7 +218,7 @@ bool ReplayMode::StartDuel() {
size_t slen = cur_replay.ReadInt16(); size_t slen = cur_replay.ReadInt16();
cur_replay.ReadData(filename, slen); cur_replay.ReadData(filename, slen);
filename[slen] = 0; filename[slen] = 0;
if(!preload_script(pduel, filename, slen)) { if(!preload_script(pduel, filename, 0)) {
return false; return false;
} }
} }
...@@ -280,7 +280,6 @@ void ReplayMode::Undo() { ...@@ -280,7 +280,6 @@ void ReplayMode::Undo() {
return; return;
mainGame->dInfo.isReplaySkiping = true; mainGame->dInfo.isReplaySkiping = true;
Restart(false); Restart(false);
mainGame->gMutex.Lock();
Pause(false, false); Pause(false, false);
} }
bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) { bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
...@@ -497,6 +496,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) { ...@@ -497,6 +496,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
break; break;
} }
case MSG_SHUFFLE_SET_CARD: { case MSG_SHUFFLE_SET_CARD: {
pbuf++;
count = BufferIO::ReadInt8(pbuf); count = BufferIO::ReadInt8(pbuf);
pbuf += count * 8; pbuf += count * 8;
DuelClient::ClientAnalyze(offset, pbuf - offset); DuelClient::ClientAnalyze(offset, pbuf - offset);
...@@ -935,6 +935,15 @@ void ReplayMode::ReplayReload() { ...@@ -935,6 +935,15 @@ void ReplayMode::ReplayReload() {
/*len = */query_field_card(pduel, 1, LOCATION_REMOVED, flag, queryBuffer, 0); /*len = */query_field_card(pduel, 1, LOCATION_REMOVED, flag, queryBuffer, 0);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(1), LOCATION_REMOVED, (char*)queryBuffer); mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(1), LOCATION_REMOVED, (char*)queryBuffer);
} }
byte* ReplayMode::ScriptReaderEx(const char* script_name, int* slen) {
char sname[256] = "./expansions";
strcat(sname, script_name + 1);//default script name: ./script/c%d.lua
byte* buffer = default_script_reader(sname, slen);
if(buffer)
return buffer;
else
return default_script_reader(script_name, slen);
}
int ReplayMode::MessageHandler(long fduel, int type) { int ReplayMode::MessageHandler(long fduel, int type) {
if(!enable_log) if(!enable_log)
return 0; return 0;
......
...@@ -47,6 +47,7 @@ public: ...@@ -47,6 +47,7 @@ public:
static void ReplayRefreshSingle(int player, int location, int sequence, int flag = 0xf81fff); static void ReplayRefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static void ReplayReload(); static void ReplayReload();
static byte* ScriptReaderEx(const char* script_name, int* slen);
static int MessageHandler(long fduel, int type); static int MessageHandler(long fduel, int type);
}; };
......
...@@ -2,9 +2,7 @@ ...@@ -2,9 +2,7 @@
#include "netserver.h" #include "netserver.h"
#include "game.h" #include "game.h"
#include "../ocgcore/ocgapi.h" #include "../ocgcore/ocgapi.h"
#include "../ocgcore/card.h" #include "../ocgcore/common.h"
#include "../ocgcore/duel.h"
#include "../ocgcore/field.h"
#include "../ocgcore/mtrandom.h" #include "../ocgcore/mtrandom.h"
namespace ygo { namespace ygo {
...@@ -408,7 +406,7 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) { ...@@ -408,7 +406,7 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
} }
time_limit[0] = host_info.time_limit; time_limit[0] = host_info.time_limit;
time_limit[1] = host_info.time_limit; time_limit[1] = host_info.time_limit;
set_script_reader(default_script_reader); set_script_reader((script_reader)ScriptReaderEx);
set_card_reader((card_reader)DataManager::CardReader); set_card_reader((card_reader)DataManager::CardReader);
set_message_handler((message_handler)SingleDuel::MessageHandler); set_message_handler((message_handler)SingleDuel::MessageHandler);
rnd.reset(seed); rnd.reset(seed);
...@@ -874,14 +872,21 @@ int SingleDuel::Analyze(char* msgbuffer, unsigned int len) { ...@@ -874,14 +872,21 @@ int SingleDuel::Analyze(char* msgbuffer, unsigned int len) {
break; break;
} }
case MSG_SHUFFLE_SET_CARD: { case MSG_SHUFFLE_SET_CARD: {
int loc = BufferIO::ReadInt8(pbuf);
count = BufferIO::ReadInt8(pbuf); count = BufferIO::ReadInt8(pbuf);
pbuf += count * 8; pbuf += count * 8;
NetServer::SendBufferToPlayer(players[0], STOC_GAME_MSG, offset, pbuf - offset); NetServer::SendBufferToPlayer(players[0], STOC_GAME_MSG, offset, pbuf - offset);
NetServer::ReSendToPlayer(players[1]); NetServer::ReSendToPlayer(players[1]);
for(auto oit = observers.begin(); oit != observers.end(); ++oit) for(auto oit = observers.begin(); oit != observers.end(); ++oit)
NetServer::ReSendToPlayer(*oit); NetServer::ReSendToPlayer(*oit);
RefreshMzone(0, 0x181fff, 0); if(loc == LOCATION_MZONE) {
RefreshMzone(1, 0x181fff, 0); RefreshMzone(0, 0x181fff, 0);
RefreshMzone(1, 0x181fff, 0);
}
else {
RefreshSzone(0, 0x181fff, 0);
RefreshSzone(1, 0x181fff, 0);
}
break; break;
} }
case MSG_NEW_TURN: { case MSG_NEW_TURN: {
...@@ -1482,18 +1487,17 @@ void SingleDuel::RefreshHand(int player, int flag, int use_cache) { ...@@ -1482,18 +1487,17 @@ void SingleDuel::RefreshHand(int player, int flag, int use_cache) {
BufferIO::WriteInt8(qbuf, MSG_UPDATE_DATA); BufferIO::WriteInt8(qbuf, MSG_UPDATE_DATA);
BufferIO::WriteInt8(qbuf, player); BufferIO::WriteInt8(qbuf, player);
BufferIO::WriteInt8(qbuf, LOCATION_HAND); BufferIO::WriteInt8(qbuf, LOCATION_HAND);
int len = query_field_card(pduel, player, LOCATION_HAND, flag | QUERY_IS_PUBLIC, (unsigned char*)qbuf, use_cache); int len = query_field_card(pduel, player, LOCATION_HAND, flag | QUERY_POSITION, (unsigned char*)qbuf, use_cache);
NetServer::SendBufferToPlayer(players[player], STOC_GAME_MSG, query_buffer, len + 3); NetServer::SendBufferToPlayer(players[player], STOC_GAME_MSG, query_buffer, len + 3);
int qlen = 0; int qlen = 0;
while(qlen < len) { while(qlen < len) {
int slen = BufferIO::ReadInt32(qbuf); int slen = BufferIO::ReadInt32(qbuf);
int qflag = *(int*)qbuf; int qflag = *(int*)qbuf;
int pos = slen - 8; int offset = 8;
if(qflag & QUERY_LSCALE) if(!(qflag & QUERY_CODE))
pos -= 4; offset -= 4;
if(qflag & QUERY_RSCALE) unsigned position = ((*(int*)(qbuf + offset)) >> 24) & 0xff;
pos -= 4; if(!(position & POS_FACEUP))
if(!qbuf[pos])
memset(qbuf, 0, slen - 4); memset(qbuf, 0, slen - 4);
qbuf += slen - 4; qbuf += slen - 4;
qlen += slen; qlen += slen;
...@@ -1540,6 +1544,15 @@ void SingleDuel::RefreshSingle(int player, int location, int sequence, int flag) ...@@ -1540,6 +1544,15 @@ void SingleDuel::RefreshSingle(int player, int location, int sequence, int flag)
NetServer::ReSendToPlayer(*pit); NetServer::ReSendToPlayer(*pit);
} }
} }
byte* SingleDuel::ScriptReaderEx(const char* script_name, int* slen) {
char sname[256] = "./expansions";
strcat(sname, script_name + 1);//default script name: ./script/c%d.lua
byte* buffer = default_script_reader(sname, slen);
if(buffer)
return buffer;
else
return default_script_reader(script_name, slen);
}
int SingleDuel::MessageHandler(long fduel, int type) { int SingleDuel::MessageHandler(long fduel, int type) {
if(!enable_log) if(!enable_log)
return 0; return 0;
......
...@@ -37,7 +37,8 @@ public: ...@@ -37,7 +37,8 @@ public:
void RefreshGrave(int player, int flag = 0x81fff, int use_cache = 1); void RefreshGrave(int player, int flag = 0x81fff, int use_cache = 1);
void RefreshExtra(int player, int flag = 0x81fff, int use_cache = 1); void RefreshExtra(int player, int flag = 0x81fff, int use_cache = 1);
void RefreshSingle(int player, int location, int sequence, int flag = 0xf81fff); void RefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static byte* ScriptReaderEx(const char* script_name, int* slen);
static int MessageHandler(long fduel, int type); static int MessageHandler(long fduel, int type);
static void SingleTimer(evutil_socket_t fd, short events, void* arg); static void SingleTimer(evutil_socket_t fd, short events, void* arg);
......
#include "single_mode.h" #include "single_mode.h"
#include "duelclient.h" #include "duelclient.h"
#include "game.h" #include "game.h"
#include "../ocgcore/duel.h" #include "../ocgcore/common.h"
#include "../ocgcore/field.h"
#include "../ocgcore/mtrandom.h" #include "../ocgcore/mtrandom.h"
namespace ygo { namespace ygo {
...@@ -39,7 +38,7 @@ int SingleMode::SinglePlayThread(void* param) { ...@@ -39,7 +38,7 @@ int SingleMode::SinglePlayThread(void* param) {
mtrandom rnd; mtrandom rnd;
time_t seed = time(0); time_t seed = time(0);
rnd.reset(seed); rnd.reset(seed);
set_script_reader((script_reader)ScriptReader); set_script_reader((script_reader)ScriptReaderEx);
set_card_reader((card_reader)DataManager::CardReader); set_card_reader((card_reader)DataManager::CardReader);
set_message_handler((message_handler)MessageHandler); set_message_handler((message_handler)MessageHandler);
pduel = create_duel(rnd.rand()); pduel = create_duel(rnd.rand());
...@@ -51,17 +50,18 @@ int SingleMode::SinglePlayThread(void* param) { ...@@ -51,17 +50,18 @@ int SingleMode::SinglePlayThread(void* param) {
myswprintf(mainGame->dInfo.strLP[1], L"%d", mainGame->dInfo.lp[1]); myswprintf(mainGame->dInfo.strLP[1], L"%d", mainGame->dInfo.lp[1]);
BufferIO::CopyWStr(mainGame->ebNickName->getText(), mainGame->dInfo.hostname, 20); BufferIO::CopyWStr(mainGame->ebNickName->getText(), mainGame->dInfo.hostname, 20);
mainGame->dInfo.clientname[0] = 0; mainGame->dInfo.clientname[0] = 0;
mainGame->dInfo.player_type = 0;
mainGame->dInfo.turn = 0; mainGame->dInfo.turn = 0;
char filename[256]; char filename[256];
size_t slen = 0; size_t slen = 0;
if(open_file) { if(open_file) {
open_file = false; open_file = false;
slen = BufferIO::EncodeUTF8(open_file_name, filename); slen = BufferIO::EncodeUTF8(open_file_name, filename);
if(!preload_script(pduel, filename, slen)) { if(!preload_script(pduel, filename, 0)) {
wchar_t fname[256]; wchar_t fname[256];
myswprintf(fname, L"./single/%ls", open_file_name); myswprintf(fname, L"./single/%ls", open_file_name);
slen = BufferIO::EncodeUTF8(fname, filename); slen = BufferIO::EncodeUTF8(fname, filename);
if(!preload_script(pduel, filename, slen)) if(!preload_script(pduel, filename, 0))
slen = 0; slen = 0;
} }
} else { } else {
...@@ -69,7 +69,7 @@ int SingleMode::SinglePlayThread(void* param) { ...@@ -69,7 +69,7 @@ int SingleMode::SinglePlayThread(void* param) {
wchar_t fname[256]; wchar_t fname[256];
myswprintf(fname, L"./single/%ls", name); myswprintf(fname, L"./single/%ls", name);
slen = BufferIO::EncodeUTF8(fname, filename); slen = BufferIO::EncodeUTF8(fname, filename);
if(!preload_script(pduel, filename, slen)) if(!preload_script(pduel, filename, 0))
slen = 0; slen = 0;
} }
if(slen == 0) { if(slen == 0) {
...@@ -83,16 +83,11 @@ int SingleMode::SinglePlayThread(void* param) { ...@@ -83,16 +83,11 @@ int SingleMode::SinglePlayThread(void* param) {
rh.seed = seed; rh.seed = seed;
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
mainGame->HideElement(mainGame->wSinglePlay); mainGame->HideElement(mainGame->wSinglePlay);
mainGame->ClearCardInfo();
mainGame->wCardImg->setVisible(true); mainGame->wCardImg->setVisible(true);
mainGame->wInfos->setVisible(true); mainGame->wInfos->setVisible(true);
mainGame->btnLeaveGame->setVisible(true); mainGame->btnLeaveGame->setVisible(true);
mainGame->btnLeaveGame->setText(dataManager.GetSysString(1210)); mainGame->btnLeaveGame->setText(dataManager.GetSysString(1210));
mainGame->stName->setText(L"");
mainGame->stInfo->setText(L"");
mainGame->stDataInfo->setText(L"");
mainGame->stSetName->setText(L"");
mainGame->stText->setText(L"");
mainGame->scrCardText->setVisible(false);
mainGame->wPhase->setVisible(true); mainGame->wPhase->setVisible(true);
mainGame->dField.Clear(); mainGame->dField.Clear();
mainGame->dInfo.isFirst = true; mainGame->dInfo.isFirst = true;
...@@ -133,18 +128,25 @@ int SingleMode::SinglePlayThread(void* param) { ...@@ -133,18 +128,25 @@ int SingleMode::SinglePlayThread(void* param) {
} }
last_replay.EndRecord(); last_replay.EndRecord();
time_t nowtime = time(NULL); time_t nowtime = time(NULL);
struct tm *localedtime = localtime(&nowtime); tm* localedtime = localtime(&nowtime);
char timebuf[40]; wchar_t timetext[40];
strftime(timebuf, 40, "%Y-%m-%d %H-%M-%S", localedtime); wcsftime(timetext, 40, L"%Y-%m-%d %H-%M-%S", localedtime);
size_t size = strlen(timebuf) + 1;
wchar_t timetext[80];
mbstowcs(timetext, timebuf, size);
mainGame->ebRSName->setText(timetext); mainGame->ebRSName->setText(timetext);
mainGame->wReplaySave->setText(dataManager.GetSysString(1340)); if(!mainGame->chkAutoSaveReplay->isChecked()) {
mainGame->PopupElement(mainGame->wReplaySave); mainGame->wReplaySave->setText(dataManager.GetSysString(1340));
mainGame->gMutex.Unlock(); mainGame->PopupElement(mainGame->wReplaySave);
mainGame->replaySignal.Reset(); mainGame->gMutex.Unlock();
mainGame->replaySignal.Wait(); mainGame->replaySignal.Reset();
mainGame->replaySignal.Wait();
} else {
mainGame->actionParam = 1;
wchar_t msgbuf[256];
myswprintf(msgbuf, dataManager.GetSysString(1367), timetext);
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->guiFont, msgbuf);
mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->gMutex.Unlock();
mainGame->WaitFrameSignal(30);
}
if(mainGame->actionParam) if(mainGame->actionParam)
last_replay.SaveReplay(mainGame->ebRSName->getText()); last_replay.SaveReplay(mainGame->ebRSName->getText());
end_duel(pduel); end_duel(pduel);
...@@ -415,6 +417,7 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) { ...@@ -415,6 +417,7 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
break; break;
} }
case MSG_SHUFFLE_SET_CARD: { case MSG_SHUFFLE_SET_CARD: {
pbuf++;
count = BufferIO::ReadInt8(pbuf); count = BufferIO::ReadInt8(pbuf);
pbuf += count * 8; pbuf += count * 8;
DuelClient::ClientAnalyze(offset, pbuf - offset); DuelClient::ClientAnalyze(offset, pbuf - offset);
...@@ -723,70 +726,25 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) { ...@@ -723,70 +726,25 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
break; break;
} }
case MSG_RELOAD_FIELD: { case MSG_RELOAD_FIELD: {
mainGame->gMutex.Lock(); pbuf++;
mainGame->dField.Clear();
mainGame->dInfo.duel_rule = BufferIO::ReadInt8(pbuf);
int val = 0;
for(int p = 0; p < 2; ++p) { for(int p = 0; p < 2; ++p) {
mainGame->dInfo.lp[p] = BufferIO::ReadInt32(pbuf); pbuf += 4;
myswprintf(mainGame->dInfo.strLP[p], L"%d", mainGame->dInfo.lp[p]);
for(int seq = 0; seq < 7; ++seq) { for(int seq = 0; seq < 7; ++seq) {
val = BufferIO::ReadInt8(pbuf); int val = BufferIO::ReadInt8(pbuf);
if(val) { if(val)
ClientCard* ccard = new ClientCard; pbuf += 2;
mainGame->dField.AddCard(ccard, p, LOCATION_MZONE, seq);
ccard->position = BufferIO::ReadInt8(pbuf);
val = BufferIO::ReadInt8(pbuf);
if(val) {
for(int xyz = 0; xyz < val; ++xyz) {
ClientCard* xcard = new ClientCard;
ccard->overlayed.push_back(xcard);
mainGame->dField.overlay_cards.insert(xcard);
xcard->overlayTarget = ccard;
xcard->location = 0x80;
xcard->sequence = ccard->overlayed.size() - 1;
}
}
}
} }
for(int seq = 0; seq < 8; ++seq) { for(int seq = 0; seq < 8; ++seq) {
val = BufferIO::ReadInt8(pbuf); int val = BufferIO::ReadInt8(pbuf);
if(val) { if(val)
ClientCard* ccard = new ClientCard; pbuf++;
mainGame->dField.AddCard(ccard, p, LOCATION_SZONE, seq);
ccard->position = BufferIO::ReadInt8(pbuf);
}
}
val = BufferIO::ReadInt8(pbuf);
for(int seq = 0; seq < val; ++seq) {
ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_DECK, seq);
} }
val = BufferIO::ReadInt8(pbuf); pbuf += 6;
for(int seq = 0; seq < val; ++seq) {
ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_HAND, seq);
}
val = BufferIO::ReadInt8(pbuf);
for(int seq = 0; seq < val; ++seq) {
ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_GRAVE, seq);
}
val = BufferIO::ReadInt8(pbuf);
for(int seq = 0; seq < val; ++seq) {
ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_REMOVED, seq);
}
val = BufferIO::ReadInt8(pbuf);
for(int seq = 0; seq < val; ++seq) {
ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_EXTRA, seq);
}
val = BufferIO::ReadInt8(pbuf);
mainGame->dField.extra_p_count[p] = val;
} }
BufferIO::ReadInt8(pbuf); //chain count, always 0 pbuf++;
DuelClient::ClientAnalyze(offset, pbuf - offset);
SinglePlayReload(); SinglePlayReload();
mainGame->gMutex.Lock();
mainGame->dField.RefreshAllCards(); mainGame->dField.RefreshAllCards();
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
break; break;
...@@ -894,6 +852,14 @@ void SingleMode::SinglePlayReload() { ...@@ -894,6 +852,14 @@ void SingleMode::SinglePlayReload() {
/*len = */query_field_card(pduel, 1, LOCATION_REMOVED, flag, queryBuffer, 0); /*len = */query_field_card(pduel, 1, LOCATION_REMOVED, flag, queryBuffer, 0);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(1), LOCATION_REMOVED, (char*)queryBuffer); mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(1), LOCATION_REMOVED, (char*)queryBuffer);
} }
byte* SingleMode::ScriptReaderEx(const char* script_name, int* slen) {
char sname[256] = "./expansions";
strcat(sname, script_name + 1);//default script name: ./script/c%d.lua
if(ScriptReader(sname, slen))
return buffer;
else
return ScriptReader(script_name, slen);
}
byte* SingleMode::ScriptReader(const char* script_name, int* slen) { byte* SingleMode::ScriptReader(const char* script_name, int* slen) {
FILE *fp; FILE *fp;
#ifdef _WIN32 #ifdef _WIN32
......
...@@ -26,6 +26,7 @@ public: ...@@ -26,6 +26,7 @@ public:
static void SinglePlayRefreshSingle(int player, int location, int sequence, int flag = 0xf81fff); static void SinglePlayRefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static void SinglePlayReload(); static void SinglePlayReload();
static byte* ScriptReaderEx(const char* script_name, int* slen);
static byte* ScriptReader(const char* script_name, int* slen); static byte* ScriptReader(const char* script_name, int* slen);
static int MessageHandler(long fduel, int type); static int MessageHandler(long fduel, int type);
......
#include "sound_manager.h" #include "sound_manager.h"
#ifndef _WIN32
#include <dirent.h>
#endif
#ifdef IRRKLANG_STATIC #ifdef IRRKLANG_STATIC
#include "../ikpmp3/ikpMP3.h" #include "../ikpmp3/ikpMP3.h"
#endif #endif
...@@ -30,51 +27,23 @@ bool SoundManager::Init() { ...@@ -30,51 +27,23 @@ bool SoundManager::Init() {
} }
void SoundManager::RefreshBGMList() { void SoundManager::RefreshBGMList() {
RefershBGMDir(L"", BGM_DUEL); RefershBGMDir(L"", BGM_DUEL);
RefershBGMDir(L"duel/", BGM_DUEL); RefershBGMDir(L"duel", BGM_DUEL);
RefershBGMDir(L"menu/", BGM_MENU); RefershBGMDir(L"menu", BGM_MENU);
RefershBGMDir(L"deck/", BGM_DECK); RefershBGMDir(L"deck", BGM_DECK);
RefershBGMDir(L"advantage/", BGM_ADVANTAGE); RefershBGMDir(L"advantage", BGM_ADVANTAGE);
RefershBGMDir(L"disadvantage/", BGM_DISADVANTAGE); RefershBGMDir(L"disadvantage", BGM_DISADVANTAGE);
RefershBGMDir(L"win/", BGM_WIN); RefershBGMDir(L"win", BGM_WIN);
RefershBGMDir(L"lose/", BGM_LOSE); RefershBGMDir(L"lose", BGM_LOSE);
} }
void SoundManager::RefershBGMDir(std::wstring path, int scene) { void SoundManager::RefershBGMDir(std::wstring path, int scene) {
#ifdef _WIN32 std::wstring search = L"./sound/BGM/" + path;
WIN32_FIND_DATAW fdataw; FileSystem::TraversalDir(search.c_str(), [this, &path, scene](const wchar_t* name, bool isdir) {
std::wstring search = L"./sound/BGM/" + path + L"*.*"; if(!isdir && wcsrchr(name, '.') && (!mywcsncasecmp(wcsrchr(name, '.'), L".mp3", 4) || !mywcsncasecmp(wcsrchr(name, '.'), L".ogg", 4))) {
HANDLE fh = FindFirstFileW(search.c_str(), &fdataw); std::wstring filename = path + L"/" + name;
if(fh == INVALID_HANDLE_VALUE) BGMList[BGM_ALL].push_back(filename);
return; BGMList[scene].push_back(filename);
do { }
size_t len = wcslen(fdataw.cFileName); });
if((fdataw.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) || len < 5
|| !(_wcsicmp(fdataw.cFileName + len - 4, L".mp3") == 0 || _wcsicmp(fdataw.cFileName + len - 4, L".ogg") == 0))
continue;
std::wstring filename = path + (std::wstring)fdataw.cFileName;
BGMList[BGM_ALL].push_back(filename);
BGMList[scene].push_back(filename);
} while(FindNextFileW(fh, &fdataw));
FindClose(fh);
#else
DIR * dir;
struct dirent * dirp;
std::wstring wsearchpath = L"./sound/BGM/" + path;
char searchpath[256];
BufferIO::EncodeUTF8(wsearchpath.c_str(), searchpath);
if((dir = opendir(searchpath)) == NULL)
return;
while((dirp = readdir(dir)) != NULL) {
size_t len = strlen(dirp->d_name);
if(len < 5 || !(strcasecmp(dirp->d_name + len - 4, ".mp3") == 0 || strcasecmp(dirp->d_name + len - 4, ".ogg")))
continue;
wchar_t wname[256];
BufferIO::DecodeUTF8(dirp->d_name, wname);
std::wstring filename = path + (std::wstring)wname;
BGMList[BGM_ALL].push_back(filename);
BGMList[scene].push_back(filename);
}
closedir(dir);
#endif
} }
void SoundManager::PlaySoundEffect(int sound) { void SoundManager::PlaySoundEffect(int sound) {
#ifdef YGOPRO_USE_IRRKLANG #ifdef YGOPRO_USE_IRRKLANG
......
...@@ -2,9 +2,7 @@ ...@@ -2,9 +2,7 @@
#include "netserver.h" #include "netserver.h"
#include "game.h" #include "game.h"
#include "../ocgcore/ocgapi.h" #include "../ocgcore/ocgapi.h"
#include "../ocgcore/card.h" #include "../ocgcore/common.h"
#include "../ocgcore/duel.h"
#include "../ocgcore/field.h"
#include "../ocgcore/mtrandom.h" #include "../ocgcore/mtrandom.h"
namespace ygo { namespace ygo {
...@@ -383,7 +381,7 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) { ...@@ -383,7 +381,7 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
} }
time_limit[0] = host_info.time_limit; time_limit[0] = host_info.time_limit;
time_limit[1] = host_info.time_limit; time_limit[1] = host_info.time_limit;
set_script_reader(default_script_reader); set_script_reader((script_reader)ScriptReaderEx);
set_card_reader((card_reader)DataManager::CardReader); set_card_reader((card_reader)DataManager::CardReader);
set_message_handler((message_handler)TagDuel::MessageHandler); set_message_handler((message_handler)TagDuel::MessageHandler);
rnd.reset(seed); rnd.reset(seed);
...@@ -832,6 +830,7 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) { ...@@ -832,6 +830,7 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) {
break; break;
} }
case MSG_SHUFFLE_SET_CARD: { case MSG_SHUFFLE_SET_CARD: {
int loc = BufferIO::ReadInt8(pbuf);
count = BufferIO::ReadInt8(pbuf); count = BufferIO::ReadInt8(pbuf);
pbuf += count * 8; pbuf += count * 8;
NetServer::SendBufferToPlayer(players[0], STOC_GAME_MSG, offset, pbuf - offset); NetServer::SendBufferToPlayer(players[0], STOC_GAME_MSG, offset, pbuf - offset);
...@@ -840,8 +839,13 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) { ...@@ -840,8 +839,13 @@ int TagDuel::Analyze(char* msgbuffer, unsigned int len) {
NetServer::ReSendToPlayer(players[3]); NetServer::ReSendToPlayer(players[3]);
for(auto oit = observers.begin(); oit != observers.end(); ++oit) for(auto oit = observers.begin(); oit != observers.end(); ++oit)
NetServer::ReSendToPlayer(*oit); NetServer::ReSendToPlayer(*oit);
RefreshMzone(0, 0x181fff, 0); if(loc == LOCATION_MZONE) {
RefreshMzone(1, 0x181fff, 0); RefreshMzone(0, 0x181fff, 0);
RefreshMzone(1, 0x181fff, 0);
} else {
RefreshSzone(0, 0x181fff, 0);
RefreshSzone(1, 0x181fff, 0);
}
break; break;
} }
case MSG_NEW_TURN: { case MSG_NEW_TURN: {
...@@ -1522,7 +1526,7 @@ void TagDuel::TimeConfirm(DuelPlayer* dp) { ...@@ -1522,7 +1526,7 @@ void TagDuel::TimeConfirm(DuelPlayer* dp) {
event_add(etimer, &timeout); event_add(etimer, &timeout);
} }
void TagDuel::RefreshMzone(int player, int flag, int use_cache) { void TagDuel::RefreshMzone(int player, int flag, int use_cache) {
char query_buffer[0x2000]; char query_buffer[0x4000];
char* qbuf = query_buffer; char* qbuf = query_buffer;
BufferIO::WriteInt8(qbuf, MSG_UPDATE_DATA); BufferIO::WriteInt8(qbuf, MSG_UPDATE_DATA);
BufferIO::WriteInt8(qbuf, player); BufferIO::WriteInt8(qbuf, player);
...@@ -1548,7 +1552,7 @@ void TagDuel::RefreshMzone(int player, int flag, int use_cache) { ...@@ -1548,7 +1552,7 @@ void TagDuel::RefreshMzone(int player, int flag, int use_cache) {
NetServer::ReSendToPlayer(*pit); NetServer::ReSendToPlayer(*pit);
} }
void TagDuel::RefreshSzone(int player, int flag, int use_cache) { void TagDuel::RefreshSzone(int player, int flag, int use_cache) {
char query_buffer[0x2000]; char query_buffer[0x4000];
char* qbuf = query_buffer; char* qbuf = query_buffer;
BufferIO::WriteInt8(qbuf, MSG_UPDATE_DATA); BufferIO::WriteInt8(qbuf, MSG_UPDATE_DATA);
BufferIO::WriteInt8(qbuf, player); BufferIO::WriteInt8(qbuf, player);
...@@ -1574,23 +1578,22 @@ void TagDuel::RefreshSzone(int player, int flag, int use_cache) { ...@@ -1574,23 +1578,22 @@ void TagDuel::RefreshSzone(int player, int flag, int use_cache) {
NetServer::ReSendToPlayer(*pit); NetServer::ReSendToPlayer(*pit);
} }
void TagDuel::RefreshHand(int player, int flag, int use_cache) { void TagDuel::RefreshHand(int player, int flag, int use_cache) {
char query_buffer[0x2000]; char query_buffer[0x4000];
char* qbuf = query_buffer; char* qbuf = query_buffer;
BufferIO::WriteInt8(qbuf, MSG_UPDATE_DATA); BufferIO::WriteInt8(qbuf, MSG_UPDATE_DATA);
BufferIO::WriteInt8(qbuf, player); BufferIO::WriteInt8(qbuf, player);
BufferIO::WriteInt8(qbuf, LOCATION_HAND); BufferIO::WriteInt8(qbuf, LOCATION_HAND);
int len = query_field_card(pduel, player, LOCATION_HAND, flag | QUERY_IS_PUBLIC, (unsigned char*)qbuf, use_cache); int len = query_field_card(pduel, player, LOCATION_HAND, flag | QUERY_POSITION, (unsigned char*)qbuf, use_cache);
NetServer::SendBufferToPlayer(cur_player[player], STOC_GAME_MSG, query_buffer, len + 3); NetServer::SendBufferToPlayer(cur_player[player], STOC_GAME_MSG, query_buffer, len + 3);
int qlen = 0; int qlen = 0;
while(qlen < len) { while(qlen < len) {
int slen = BufferIO::ReadInt32(qbuf); int slen = BufferIO::ReadInt32(qbuf);
int qflag = *(int*)qbuf; int qflag = *(int*)qbuf;
int pos = slen - 8; int offset = 8;
if(qflag & QUERY_LSCALE) if(!(qflag & QUERY_CODE))
pos -= 4; offset -= 4;
if(qflag & QUERY_RSCALE) unsigned position = ((*(int*)(qbuf + offset)) >> 24) & 0xff;
pos -= 4; if(!(position & POS_FACEUP))
if(!qbuf[pos])
memset(qbuf, 0, slen - 4); memset(qbuf, 0, slen - 4);
qbuf += slen - 4; qbuf += slen - 4;
qlen += slen; qlen += slen;
...@@ -1602,7 +1605,7 @@ void TagDuel::RefreshHand(int player, int flag, int use_cache) { ...@@ -1602,7 +1605,7 @@ void TagDuel::RefreshHand(int player, int flag, int use_cache) {
NetServer::ReSendToPlayer(*pit); NetServer::ReSendToPlayer(*pit);
} }
void TagDuel::RefreshGrave(int player, int flag, int use_cache) { void TagDuel::RefreshGrave(int player, int flag, int use_cache) {
char query_buffer[0x2000]; char query_buffer[0x4000];
char* qbuf = query_buffer; char* qbuf = query_buffer;
BufferIO::WriteInt8(qbuf, MSG_UPDATE_DATA); BufferIO::WriteInt8(qbuf, MSG_UPDATE_DATA);
BufferIO::WriteInt8(qbuf, player); BufferIO::WriteInt8(qbuf, player);
...@@ -1616,7 +1619,7 @@ void TagDuel::RefreshGrave(int player, int flag, int use_cache) { ...@@ -1616,7 +1619,7 @@ void TagDuel::RefreshGrave(int player, int flag, int use_cache) {
NetServer::ReSendToPlayer(*pit); NetServer::ReSendToPlayer(*pit);
} }
void TagDuel::RefreshExtra(int player, int flag, int use_cache) { void TagDuel::RefreshExtra(int player, int flag, int use_cache) {
char query_buffer[0x2000]; char query_buffer[0x4000];
char* qbuf = query_buffer; char* qbuf = query_buffer;
BufferIO::WriteInt8(qbuf, MSG_UPDATE_DATA); BufferIO::WriteInt8(qbuf, MSG_UPDATE_DATA);
BufferIO::WriteInt8(qbuf, player); BufferIO::WriteInt8(qbuf, player);
...@@ -1625,7 +1628,7 @@ void TagDuel::RefreshExtra(int player, int flag, int use_cache) { ...@@ -1625,7 +1628,7 @@ void TagDuel::RefreshExtra(int player, int flag, int use_cache) {
NetServer::SendBufferToPlayer(cur_player[player], STOC_GAME_MSG, query_buffer, len + 3); NetServer::SendBufferToPlayer(cur_player[player], STOC_GAME_MSG, query_buffer, len + 3);
} }
void TagDuel::RefreshSingle(int player, int location, int sequence, int flag) { void TagDuel::RefreshSingle(int player, int location, int sequence, int flag) {
char query_buffer[0x2000]; char query_buffer[0x4000];
char* qbuf = query_buffer; char* qbuf = query_buffer;
BufferIO::WriteInt8(qbuf, MSG_UPDATE_CARD); BufferIO::WriteInt8(qbuf, MSG_UPDATE_CARD);
BufferIO::WriteInt8(qbuf, player); BufferIO::WriteInt8(qbuf, player);
...@@ -1658,6 +1661,15 @@ void TagDuel::RefreshSingle(int player, int location, int sequence, int flag) { ...@@ -1658,6 +1661,15 @@ void TagDuel::RefreshSingle(int player, int location, int sequence, int flag) {
} }
} }
} }
byte* TagDuel::ScriptReaderEx(const char* script_name, int* slen) {
char sname[256] = "./expansions";
strcat(sname, script_name + 1);//default script name: ./script/c%d.lua
byte* buffer = default_script_reader(sname, slen);
if(buffer)
return buffer;
else
return default_script_reader(script_name, slen);
}
int TagDuel::MessageHandler(long fduel, int type) { int TagDuel::MessageHandler(long fduel, int type) {
if(!enable_log) if(!enable_log)
return 0; return 0;
......
...@@ -37,7 +37,8 @@ public: ...@@ -37,7 +37,8 @@ public:
void RefreshGrave(int player, int flag = 0x81fff, int use_cache = 1); void RefreshGrave(int player, int flag = 0x81fff, int use_cache = 1);
void RefreshExtra(int player, int flag = 0x81fff, int use_cache = 1); void RefreshExtra(int player, int flag = 0x81fff, int use_cache = 1);
void RefreshSingle(int player, int location, int sequence, int flag = 0xf81fff); void RefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static byte* ScriptReaderEx(const char* script_name, int* slen);
static int MessageHandler(long fduel, int type); static int MessageHandler(long fduel, int type);
static void TagTimer(evutil_socket_t fd, short events, void* arg); static void TagTimer(evutil_socket_t fd, short events, void* arg);
......
This diff is collapsed.
project (lua)
set (AUTO_FILES_RESULT)
AutoFiles("." "src" "\\.(cpp|c|h)$" "lua.c|luac.c")
set_source_files_properties(${AUTO_FILES_RESULT} PROPERTIES LANGUAGE CXX)
add_library (lua STATIC ${AUTO_FILES_RESULT})
This diff is collapsed.
/*
** $Id: lapi.h,v 2.9.1.1 2017/04/19 17:20:42 roberto Exp $
** Auxiliary functions from Lua API
** See Copyright Notice in lua.h
*/
#ifndef lapi_h
#define lapi_h
#include "llimits.h"
#include "lstate.h"
#define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \
"stack overflow");}
#define adjustresults(L,nres) \
{ if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; }
#define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \
"not enough elements in the stack")
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
** $Id: lctype.c,v 1.12.1.1 2017/04/19 17:20:42 roberto Exp $
** 'ctype' functions for Lua
** See Copyright Notice in lua.h
*/
#define lctype_c
#define LUA_CORE
#include "lprefix.h"
#include "lctype.h"
#if !LUA_USE_CTYPE /* { */
#include <limits.h>
LUAI_DDEF const lu_byte luai_ctype_[UCHAR_MAX + 2] = {
0x00, /* EOZ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0. */
0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1. */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, /* 2. */
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, /* 3. */
0x16, 0x16, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 4. */
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 5. */
0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x05,
0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 6. */
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 7. */
0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8. */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9. */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a. */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b. */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c. */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d. */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* e. */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* f. */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
#endif /* } */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment