port 2A step 2: copy the 40250 header closure into the port mirror
76 closure headers (EterBase, EterLocale, EterPack, EterLib, GameLib, MilesLib, EffectLib, SphereLib, EterImageLib) copied by the new port_copy.py (CP949->UTF-8, LF, include-path case only); platform-class headers go to the mirror path too, as the interface platform/ implements. Six manual `// PORT:` edits (Random, Singleton, Pool, Stl, Utils, FlyTarget). - common/D3D8Types.h: D3D8 value types with SDK values/layout, opaque COM interfaces - common/shim/sdk (d3d8/d3dx8/mss) on every platform, common/shim/win32 off Windows - Win32Types/Win32Crt: HRESULT, GUID, LARGE_INTEGER, LOGFONT/TEXTMETRIC, _atoi64, CRITICAL_SECTION on std::recursive_mutex - header gate prepends each library's StdAfx.h (40250's precompiled header) port_gate: macOS, Android, iOS, Windows (mingw) PASS; Linux BLOCKED (no toolchain). ScriptLib/EterPythonLib/UserInterface wait for 2P (their StdAfx includes Python). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -148,6 +148,9 @@ behavior verified from code inspection alone.
|
|||||||
— function inventory (active `.vcxproj` sources + the 40250 Python root), progress per library and
|
— function inventory (active `.vcxproj` sources + the 40250 Python root), progress per library and
|
||||||
per layer, and tag/port-map/layout consistency. Run `check` before every commit that touches
|
per layer, and tag/port-map/layout consistency. Run `check` before every commit that touches
|
||||||
`audit/port-map/`.
|
`audit/port-map/`.
|
||||||
|
- `scripts/port_copy.py copy <Lib/File>... | diff [<Lib/File>...]` — copy 40250 files into the
|
||||||
|
`extension/src/port/` mirror with mechanical edits only (CP949→UTF-8, LF, include-path case); `diff`
|
||||||
|
lists the manual `// PORT:` edits.
|
||||||
- `scripts/port_deps.py closure <file> | slices [--write] | order [--write]` — `#include` graph with the
|
- `scripts/port_deps.py closure <file> | slices [--write] | order [--write]` — `#include` graph with the
|
||||||
implicit edges each library's `StdAfx.h` supplies; writes the 2V0-2V3 unit lists and the batch-2
|
implicit edges each library's `StdAfx.h` supplies; writes the 2V0-2V3 unit lists and the batch-2
|
||||||
topological order to `audit/slices/`. Regenerate after changing a slice definition.
|
topological order to `audit/slices/`. Regenerate after changing a slice definition.
|
||||||
|
|||||||
@@ -0,0 +1,141 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Copy 40250 sources into the port mirror (extension/src/port/<Lib>/<File>) with mechanical edits only.
|
||||||
|
|
||||||
|
port_copy.py copy <rel> [<rel>...] [--force] write the mechanical copy (refuses to overwrite without --force)
|
||||||
|
port_copy.py diff [<rel>...] show the manual edits: port file vs its mechanical copy
|
||||||
|
(no args: every mirrored 40250 file that differs)
|
||||||
|
|
||||||
|
`<rel>` is a reference path such as `GameLib/ActorInstance.h`, matched case-insensitively.
|
||||||
|
|
||||||
|
Mechanical edits, and nothing else:
|
||||||
|
- CP949 is decoded and written as UTF-8 (comments are Korean). A non-ASCII string or character
|
||||||
|
literal would change bytes at runtime, so such a file is refused and must be handled by hand.
|
||||||
|
- CRLF becomes LF.
|
||||||
|
- `#include "..."` paths get the on-disk case of the file they name (40250 builds on a
|
||||||
|
case-insensitive file system and writes `../eterLib/StdAfx.h`, `Parser.h` for `parser.h`, ...),
|
||||||
|
keeping the relative form, so the original include resolves the same way on every platform.
|
||||||
|
Everything else in a port file that differs from this copy is a manual edit, marked `// PORT:`.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import difflib
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import refroot # script directory is on sys.path when run directly
|
||||||
|
|
||||||
|
REPO = refroot.repo_root()
|
||||||
|
PORT = REPO / "extension" / "src" / "port"
|
||||||
|
INCLUDE = re.compile(r'^(\s*#\s*include\s*")([^"]+)(")', re.M)
|
||||||
|
LITERAL = re.compile(r'"(?:\\.|[^"\\\n])*"|\'(?:\\.|[^\'\\\n])*\'')
|
||||||
|
COMMENT = re.compile(r"//[^\n]*|/\*.*?\*/", re.S)
|
||||||
|
|
||||||
|
|
||||||
|
def ref_index(ref: Path) -> dict[str, Path]:
|
||||||
|
return {p.relative_to(ref).as_posix().lower(): p for p in ref.rglob("*") if p.is_file()}
|
||||||
|
|
||||||
|
|
||||||
|
def canonical(ref: Path, index: dict[str, Path], path: Path) -> str:
|
||||||
|
return index[path.relative_to(ref).as_posix().lower()].relative_to(ref).as_posix()
|
||||||
|
|
||||||
|
|
||||||
|
def resolve(ref: Path, index: dict[str, Path], rel: str) -> Path:
|
||||||
|
hit = index.get(rel.replace("\\", "/").lower())
|
||||||
|
if not hit:
|
||||||
|
raise SystemExit(f"{rel}: not in the 40250 reference tree")
|
||||||
|
return hit
|
||||||
|
|
||||||
|
|
||||||
|
def fix_include(ref: Path, index: dict[str, Path], src: Path, target: str) -> str:
|
||||||
|
base = src.parent.relative_to(ref).as_posix()
|
||||||
|
parts = [] if base == "." else base.split("/")
|
||||||
|
for piece in target.replace("\\", "/").split("/"):
|
||||||
|
if piece == "..":
|
||||||
|
if not parts:
|
||||||
|
return target
|
||||||
|
parts.pop()
|
||||||
|
elif piece != ".":
|
||||||
|
parts.append(piece)
|
||||||
|
hit = index.get("/".join(parts).lower())
|
||||||
|
if not hit:
|
||||||
|
return target # unresolved (commented-out or absent in 40250): leave untouched
|
||||||
|
real = hit.relative_to(ref).as_posix().split("/")
|
||||||
|
# Keep the original shape: same number of `..` and segments, only the case changes.
|
||||||
|
kept = [p for p in target.replace("\\", "/").split("/") if p in ("..", ".")]
|
||||||
|
tail = real[len(real) - (len(target.replace("\\", "/").split("/")) - len(kept)):]
|
||||||
|
return "/".join(kept + tail)
|
||||||
|
|
||||||
|
|
||||||
|
def mechanical(ref: Path, index: dict[str, Path], src: Path) -> str:
|
||||||
|
raw = src.read_bytes()
|
||||||
|
try:
|
||||||
|
text = raw.decode("cp949")
|
||||||
|
except UnicodeDecodeError as e:
|
||||||
|
raise SystemExit(f"{src.relative_to(ref)}: not CP949 ({e})")
|
||||||
|
text = text.replace("\r\n", "\n").lstrip("")
|
||||||
|
code = COMMENT.sub(lambda m: " " * len(m.group(0)), text)
|
||||||
|
bad = [m.group(0) for m in LITERAL.finditer(code) if not m.group(0).isascii()]
|
||||||
|
if bad:
|
||||||
|
raise SystemExit(f"{src.relative_to(ref)}: non-ASCII literal(s), copy by hand: {bad[:3]}")
|
||||||
|
return INCLUDE.sub(lambda m: m.group(1) + fix_include(ref, index, src, m.group(2)) + m.group(3), text)
|
||||||
|
|
||||||
|
|
||||||
|
def cmd_copy(args) -> int:
|
||||||
|
ref = refroot.reference_root()
|
||||||
|
index = ref_index(ref)
|
||||||
|
for rel in args.rel:
|
||||||
|
src = resolve(ref, index, rel)
|
||||||
|
dst = PORT / canonical(ref, index, src)
|
||||||
|
if dst.exists() and not args.force:
|
||||||
|
print(f"skip {dst.relative_to(REPO)} (exists; --force overwrites manual edits)")
|
||||||
|
continue
|
||||||
|
dst.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
dst.write_text(mechanical(ref, index, src), encoding="utf-8")
|
||||||
|
print(f"copy {dst.relative_to(REPO)}")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def cmd_diff(args) -> int:
|
||||||
|
ref = refroot.reference_root()
|
||||||
|
index = ref_index(ref)
|
||||||
|
if args.rel:
|
||||||
|
pairs = [(resolve(ref, index, r), PORT / canonical(ref, index, resolve(ref, index, r))) for r in args.rel]
|
||||||
|
else:
|
||||||
|
pairs = []
|
||||||
|
for dst in sorted(PORT.rglob("*")):
|
||||||
|
key = dst.relative_to(PORT).as_posix().lower()
|
||||||
|
if dst.is_file() and key in index and not key.startswith("common/"):
|
||||||
|
pairs.append((index[key], dst))
|
||||||
|
changed = 0
|
||||||
|
for src, dst in pairs:
|
||||||
|
if not dst.exists():
|
||||||
|
print(f"missing {dst.relative_to(REPO)}")
|
||||||
|
continue
|
||||||
|
want = mechanical(ref, index, src).splitlines(keepends=True)
|
||||||
|
have = dst.read_text(encoding="utf-8").splitlines(keepends=True)
|
||||||
|
diff = list(difflib.unified_diff(want, have, f"40250/{src.relative_to(ref).as_posix()}",
|
||||||
|
dst.relative_to(REPO).as_posix()))
|
||||||
|
if diff:
|
||||||
|
changed += 1
|
||||||
|
sys.stdout.writelines(diff)
|
||||||
|
print(f"{changed} of {len(pairs)} file(s) with manual edits", file=sys.stderr)
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> int:
|
||||||
|
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||||
|
sub = ap.add_subparsers(dest="cmd", required=True)
|
||||||
|
c = sub.add_parser("copy")
|
||||||
|
c.add_argument("rel", nargs="+")
|
||||||
|
c.add_argument("--force", action="store_true")
|
||||||
|
d = sub.add_parser("diff")
|
||||||
|
d.add_argument("rel", nargs="*")
|
||||||
|
args = ap.parse_args()
|
||||||
|
return {"copy": cmd_copy, "diff": cmd_diff}[args.cmd](args)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
||||||
@@ -49,7 +49,7 @@ LAYER_PATTERNS = [
|
|||||||
"EterLib/LensFlare.cpp", "EterLib/ScreenFilter.cpp", "EterLib/Decal.cpp", "EterLib/EnvironmentMap.cpp",
|
"EterLib/LensFlare.cpp", "EterLib/ScreenFilter.cpp", "EterLib/Decal.cpp", "EterLib/EnvironmentMap.cpp",
|
||||||
"EterLib/JpegFile.cpp", "EterLib/TargaResource.cpp", "EterLib/DibBar.cpp", "EterLib/BlockTexture.cpp",
|
"EterLib/JpegFile.cpp", "EterLib/TargaResource.cpp", "EterLib/DibBar.cpp", "EterLib/BlockTexture.cpp",
|
||||||
"EterLib/CullingManager.cpp", "EterLib/Thread.cpp", "EterLib/Mutex.cpp", "EterLib/FileLoaderThread.cpp",
|
"EterLib/CullingManager.cpp", "EterLib/Thread.cpp", "EterLib/Mutex.cpp", "EterLib/FileLoaderThread.cpp",
|
||||||
"EterLib/TextBar.cpp", "EterBase/*", "GameLib/MapOutdoorRender*.cpp", "GameLib/MapOutdoorWater.cpp",
|
"EterLib/TextBar.cpp", "EterLib/Dimm.h", "EterBase/*", "GameLib/MapOutdoorRender*.cpp", "GameLib/MapOutdoorWater.cpp",
|
||||||
"GameLib/SnowParticle.cpp", "GameLib/SnowEnvironment.cpp", "GameLib/TerrainDecal.cpp",
|
"GameLib/SnowParticle.cpp", "GameLib/SnowEnvironment.cpp", "GameLib/TerrainDecal.cpp",
|
||||||
"GameLib/TerrainPatch.cpp", "UserInterface/PythonApplicationLogo.cpp", "UserInterface/MovieMan.cpp",
|
"GameLib/TerrainPatch.cpp", "UserInterface/PythonApplicationLogo.cpp", "UserInterface/MovieMan.cpp",
|
||||||
"UserInterface/HackShield.cpp", "UserInterface/NProtectGameGuard.cpp", "UserInterface/ProcessCRC.cpp",
|
"UserInterface/HackShield.cpp", "UserInterface/NProtectGameGuard.cpp", "UserInterface/ProcessCRC.cpp",
|
||||||
|
|||||||
+30
-4
@@ -43,13 +43,21 @@ extension/src/port/GameLib/ActorInstance.cpp
|
|||||||
extension/src/port/ScriptLib/PythonLauncher.cpp
|
extension/src/port/ScriptLib/PythonLauncher.cpp
|
||||||
extension/src/port/EterPythonLib/PythonWindow*.cpp
|
extension/src/port/EterPythonLib/PythonWindow*.cpp
|
||||||
extension/src/port/UserInterface/*Module.cpp # app/net/player/chr/... Python 模块
|
extension/src/port/UserInterface/*Module.cpp # app/net/player/chr/... Python 模块
|
||||||
extension/src/platform/ # CGraphicThingInstance、CSoundManager 等同名适配接口
|
extension/src/port/EterLib/GrpBase.h # 平台类的 40250 头文件同样照抄在镜像路径(接口)
|
||||||
|
extension/src/platform/ # 这些平台类的实现(CGraphicThingInstance、CSoundManager 等)
|
||||||
extension/third_party/cpython-2.7.18/ # 静态库(2P 批次加入)
|
extension/third_party/cpython-2.7.18/ # 静态库(2P 批次加入)
|
||||||
```
|
```
|
||||||
|
|
||||||
逻辑层规则:
|
逻辑层规则:
|
||||||
|
|
||||||
- 40250 调用平台类的地方,调用 `extension/src/platform/` 下同名的适配接口,ported 代码里不直接写 Godot 调用。
|
- 40250 调用平台类的地方,调用 `extension/src/platform/` 下同名的适配接口,ported 代码里不直接写 Godot 调用。
|
||||||
|
闭包里的 40250 头文件**不分逻辑层和平台层,一律照抄到镜像路径**(`port/EterLib/GrpBase.h` 等),作为平台类的接口,
|
||||||
|
这样原来的相对 include(`../eterLib/StdAfx.h`)保持不变;`platform/` 只放这些类的 `.cpp` 实现,不另写同名头文件。
|
||||||
|
- 照抄只做机械转换,用 `port_copy.py copy <Lib/File>`:CP949 转 UTF-8、CRLF 转 LF、`#include "..."` 路径改成磁盘上的
|
||||||
|
大小写;含非 ASCII 字符串字面量的文件拒绝照抄,需手工处理。其他任何改动都是手工修改,行上标 `// PORT:` 并写原因,
|
||||||
|
`port_copy.py diff` 列出全部手工修改。
|
||||||
|
- 40250 源码里的系统头保持原样 include,由 `port/common/shim/` 提供替身:`shim/sdk/`(`d3d8.h`、`d3dx8.h`、`mss.h`,
|
||||||
|
所有平台都用,只含值类型和不透明接口)、`shim/win32/`(`windows.h`、`winsock.h`、`mmsystem.h` 等,仅非 Windows 平台用)。
|
||||||
- 40250 的单例(`CPythonPlayer`、`CPythonCharacterManager`、`CPythonNetworkStream`)归扩展所有,GDScript 不持有玩法状态。
|
- 40250 的单例(`CPythonPlayer`、`CPythonCharacterManager`、`CPythonNetworkStream`)归扩展所有,GDScript 不持有玩法状态。
|
||||||
- **保持 40250 的宽度和溢出语义,不是机械保留 C++ 类型名。** 40250 可执行文件目标是 32 位 Win32(ILP32):
|
- **保持 40250 的宽度和溢出语义,不是机械保留 C++ 类型名。** 40250 可执行文件目标是 32 位 Win32(ILP32):
|
||||||
`long`/`unsigned long` 和指针都是 32 位;移植目标则可能是 LP64 或 LLP64。`port/common/Win32Types.h`(批次 2A)
|
`long`/`unsigned long` 和指针都是 32 位;移植目标则可能是 LP64 或 LLP64。`port/common/Win32Types.h`(批次 2A)
|
||||||
@@ -133,13 +141,31 @@ extension/third_party/cpython-2.7.18/ # 静态库(2P 批次
|
|||||||
- 2V3 切片用到的 `D3DXVec*`、`D3DXMatrix*`、`D3DXQuaternion*` 函数,采用行向量、左手旋转、D3DX 的乘法顺序;
|
- 2V3 切片用到的 `D3DXVec*`、`D3DXMatrix*`、`D3DXQuaternion*` 函数,采用行向量、左手旋转、D3DX 的乘法顺序;
|
||||||
后续单元用到新函数时再按需补。
|
后续单元用到新函数时再按需补。
|
||||||
|
|
||||||
这一层不包含 D3D8 渲染枚举和结构(`D3DLIGHT8`、`D3DRS_*` 等),它们归 platform 层。测试在 `port.common` 里。
|
测试在 `port.common` 里。
|
||||||
- 未完成:闭包头文件照抄(步骤 2)、platform 接口骨架(步骤 4)。
|
- 已完成(步骤 2,不含依赖 Python 的库):闭包头文件照抄,76 个,覆盖 EterBase、EterLocale、EterPack、EterLib、
|
||||||
|
GameLib、MilesLib、EffectLib、SphereLib、EterImageLib。
|
||||||
|
- 门禁中每个头文件前先 include 本库的 `StdAfx.h`(40250 把它作为预编译头)。
|
||||||
|
- D3D8 的值类型(`D3DFORMAT`、`D3DCAPS8`、`D3DLIGHT8`、`D3DMATERIAL8` 等,按 SDK 取值和布局并加 `static_assert`)
|
||||||
|
放在 `port/common/D3D8Types.h`;COM 接口(`IDirect3DDevice8` 等)只做不透明声明,由 platform 持有。
|
||||||
|
- 手工 `// PORT:` 修改共 6 个文件:
|
||||||
|
- `Random.h`:`random`/`srandom` 与 POSIX 重名,改名;
|
||||||
|
- `Singleton.h`:`(int)` 指针运算改为 `intptr_t`;
|
||||||
|
- `Pool.h`:`operator new(unsigned int)` 改为 `size_t`;
|
||||||
|
- `Stl.h`:`<SSTREAM>` 改为小写;
|
||||||
|
- `Utils.h`:补 `<math.h>`;
|
||||||
|
- `FlyTarget.h`:补 `CFlyTarget` 前置声明(MSVC 会让 friend 声明可见)。
|
||||||
|
- 40250 StdAfx 里有影响语义的宏,移植逻辑时要注意:
|
||||||
|
- EterBase 的 `#define atoi _atoi64`;
|
||||||
|
- UserInterface 的 `_USE_32BIT_TIME_T`;
|
||||||
|
- `EterBase/ServiceDefs.h` 的 `_IMPROVED_PACKET_ENCRYPTION_`;
|
||||||
|
- 工程字符集是 MultiByte,所以 `TCHAR` 就是 `char`。
|
||||||
|
- ScriptLib、EterPythonLib、UserInterface 的 StdAfx 会 include Python 头,要等 2P 把 CPython 加进来之后再照抄。
|
||||||
|
- 未完成:platform 接口骨架(步骤 4);依赖 Python 的三个库的闭包头(等 2P)。
|
||||||
|
|
||||||
| 平台 | port_gate |
|
| 平台 | port_gate |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| macOS arm64 | PASS(含 `port.common` 测试) |
|
| macOS arm64 | PASS(含 `port.common` 测试) |
|
||||||
| Android arm64(NDK 27.2,API 24) | PASS |
|
| Android arm64(脚本取已装的最新 NDK,本机 28.2;API 24) | PASS |
|
||||||
| iOS arm64 | PASS(Xcode,未签名) |
|
| iOS arm64 | PASS(Xcode,未签名) |
|
||||||
| Windows x64 | mingw-w64 PASS;MSVC 需在 Windows 主机上跑,**BLOCKED** |
|
| Windows x64 | mingw-w64 PASS;MSVC 需在 Windows 主机上跑,**BLOCKED** |
|
||||||
| Linux x86_64 | **BLOCKED**(本机无 Linux 工具链;Linux 主机上直接运行脚本) |
|
| Linux x86_64 | **BLOCKED**(本机无 Linux 工具链;Linux 主机上直接运行脚本) |
|
||||||
|
|||||||
@@ -5,9 +5,29 @@
|
|||||||
|
|
||||||
file(GLOB_RECURSE MT_PORT_SOURCES CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
|
file(GLOB_RECURSE MT_PORT_SOURCES CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
|
||||||
file(GLOB_RECURSE MT_PORT_HEADERS CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
|
file(GLOB_RECURSE MT_PORT_HEADERS CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
|
||||||
|
if(WIN32)
|
||||||
|
# Stand-ins for Windows SDK headers; on Windows the real ones are used.
|
||||||
|
list(FILTER MT_PORT_HEADERS EXCLUDE REGEX "/common/shim/win32/")
|
||||||
|
endif()
|
||||||
|
|
||||||
add_library(port_logic STATIC ${MT_PORT_SOURCES})
|
add_library(port_logic STATIC ${MT_PORT_SOURCES})
|
||||||
target_include_directories(port_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
target_include_directories(port_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
# 40250 system headers the ported sources keep including verbatim: D3D8/D3DX/Miles SDK types everywhere,
|
||||||
|
# Windows/CRT ones only where the platform has none.
|
||||||
|
set(MT_PORT_SHIMS ${CMAKE_CURRENT_SOURCE_DIR}/common/shim/sdk)
|
||||||
|
if(NOT WIN32)
|
||||||
|
list(APPEND MT_PORT_SHIMS ${CMAKE_CURRENT_SOURCE_DIR}/common/shim/win32)
|
||||||
|
endif()
|
||||||
|
# EterBase/lzo.h includes <lzo/lzo1x.h>; third_party/minilzo provides that path.
|
||||||
|
list(APPEND MT_PORT_SHIMS ${CMAKE_CURRENT_SOURCE_DIR}/../../third_party/minilzo)
|
||||||
|
target_include_directories(port_logic PUBLIC ${MT_PORT_SHIMS})
|
||||||
|
# 40250 sources carry MSVC `#pragma warning(...)` lines verbatim, and non-literal printf formats
|
||||||
|
# (EterImageLib/StdAfx.h) that the Android toolchain turns into errors.
|
||||||
|
set(MT_PORT_WARNING_FLAGS)
|
||||||
|
if(NOT MSVC)
|
||||||
|
set(MT_PORT_WARNING_FLAGS -Wno-unknown-pragmas -Wno-format-security)
|
||||||
|
endif()
|
||||||
|
target_compile_options(port_logic PUBLIC ${MT_PORT_WARNING_FLAGS})
|
||||||
target_compile_features(port_logic PUBLIC cxx_std_20)
|
target_compile_features(port_logic PUBLIC cxx_std_20)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
target_link_libraries(port_logic PUBLIC winmm)
|
target_link_libraries(port_logic PUBLIC winmm)
|
||||||
@@ -36,17 +56,25 @@ foreach(src IN LISTS MT_PORT_SOURCES)
|
|||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Gate: every header under port/ compiles on its own (and twice, for its include guard), with its
|
# Gate: every header under port/ compiles on its own (and twice, for its include guard), with its
|
||||||
# library's definitions. Built by default, so every platform build enforces it.
|
# library's definitions. As in 40250, where each library's StdAfx.h is the precompiled header of
|
||||||
|
# every translation unit, the library's StdAfx.h comes first. Built by default, so every platform
|
||||||
|
# build enforces it.
|
||||||
set(MT_PORT_GATE_SOURCES)
|
set(MT_PORT_GATE_SOURCES)
|
||||||
foreach(hdr IN LISTS MT_PORT_HEADERS)
|
foreach(hdr IN LISTS MT_PORT_HEADERS)
|
||||||
file(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${hdr})
|
file(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${hdr})
|
||||||
string(MAKE_C_IDENTIFIER "${rel}" id)
|
string(MAKE_C_IDENTIFIER "${rel}" id)
|
||||||
set(tu ${CMAKE_CURRENT_BINARY_DIR}/header_gate/${id}.cpp)
|
set(tu ${CMAKE_CURRENT_BINARY_DIR}/header_gate/${id}.cpp)
|
||||||
file(CONFIGURE OUTPUT ${tu} CONTENT "#include \"${rel}\"\n#include \"${rel}\"\n")
|
string(REGEX REPLACE "/.*" "" lib "${rel}")
|
||||||
|
set(pch "")
|
||||||
|
# 40250 spells it StdAfx.h or Stdafx.h; use the on-disk name for case-sensitive hosts.
|
||||||
|
file(GLOB stdafx RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${lib}/[Ss]td[Aa]fx.h)
|
||||||
|
if(NOT lib STREQUAL "common" AND stdafx)
|
||||||
|
set(pch "#include \"${stdafx}\"\n")
|
||||||
|
endif()
|
||||||
|
file(CONFIGURE OUTPUT ${tu} CONTENT "${pch}#include \"${rel}\"\n#include \"${rel}\"\n")
|
||||||
set_property(SOURCE ${tu} APPEND PROPERTY OBJECT_DEPENDS ${hdr})
|
set_property(SOURCE ${tu} APPEND PROPERTY OBJECT_DEPENDS ${hdr})
|
||||||
list(APPEND MT_PORT_GATE_SOURCES ${tu})
|
list(APPEND MT_PORT_GATE_SOURCES ${tu})
|
||||||
# Definitions follow the header's library, not the generated file's location.
|
# Definitions follow the header's library, not the generated file's location.
|
||||||
string(REGEX REPLACE "/.*" "" lib "${rel}")
|
|
||||||
if(DEFINED MT_PORT_DEFINES_${lib})
|
if(DEFINED MT_PORT_DEFINES_${lib})
|
||||||
set_property(SOURCE ${tu} APPEND PROPERTY COMPILE_DEFINITIONS ${MT_PORT_DEFINES_${lib}})
|
set_property(SOURCE ${tu} APPEND PROPERTY COMPILE_DEFINITIONS ${MT_PORT_DEFINES_${lib}})
|
||||||
else()
|
else()
|
||||||
@@ -54,8 +82,9 @@ foreach(hdr IN LISTS MT_PORT_HEADERS)
|
|||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
add_library(port_header_gate OBJECT ${MT_PORT_GATE_SOURCES})
|
add_library(port_header_gate OBJECT ${MT_PORT_GATE_SOURCES})
|
||||||
target_include_directories(port_header_gate PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
target_include_directories(port_header_gate PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${MT_PORT_SHIMS})
|
||||||
target_compile_features(port_header_gate PRIVATE cxx_std_20)
|
target_compile_features(port_header_gate PRIVATE cxx_std_20)
|
||||||
|
target_compile_options(port_header_gate PRIVATE ${MT_PORT_WARNING_FLAGS})
|
||||||
add_dependencies(port_logic port_header_gate)
|
add_dependencies(port_logic port_header_gate)
|
||||||
|
|
||||||
if(BUILD_TESTING AND CMAKE_SYSTEM_NAME STREQUAL CMAKE_HOST_SYSTEM_NAME)
|
if(BUILD_TESTING AND CMAKE_SYSTEM_NAME STREQUAL CMAKE_HOST_SYSTEM_NAME)
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
//#include <crtdbg.h>
|
||||||
|
|
||||||
|
#include "../EterBase/StdAfx.h"
|
||||||
|
|
||||||
|
#include "../EterBase/Utils.h"
|
||||||
|
#include "../EterBase/Timer.h"
|
||||||
|
#include "../EterBase/CRC32.h"
|
||||||
|
#include "../EterBase/Debug.h"
|
||||||
|
|
||||||
|
#include "../EterLib/StdAfx.h"
|
||||||
|
#include "../EterLib/TextFileLoader.h"
|
||||||
|
|
||||||
|
#include "../MilesLib/Stdafx.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
#include "FrameController.h"
|
||||||
|
|
||||||
|
#include "EffectElementBase.h"
|
||||||
|
#include "EffectElementBaseInstance.h"
|
||||||
|
|
||||||
|
#include "ParticleProperty.h"
|
||||||
|
#include "ParticleInstance.h"
|
||||||
|
#include "EmitterProperty.h"
|
||||||
|
|
||||||
|
#include "ParticleSystemData.h"
|
||||||
|
#include "ParticleSystemInstance.h"
|
||||||
|
|
||||||
|
#include "EffectMesh.h"
|
||||||
|
#include "EffectMeshInstance.h"
|
||||||
|
|
||||||
|
#include "SimpleLightData.h"
|
||||||
|
#include "SimpleLightInstance.h"
|
||||||
|
|
||||||
|
#include "EffectData.h"
|
||||||
|
#include "EffectInstance.h"
|
||||||
|
|
||||||
|
#include "EffectManager.h"
|
||||||
|
*/
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#ifndef __INC_CRC32_H__
|
||||||
|
#define __INC_CRC32_H__
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
DWORD GetCRC32(const char* buffer, size_t count);
|
||||||
|
DWORD GetCaseCRC32(const char * buf, size_t len);
|
||||||
|
DWORD GetHFILECRC32(HANDLE hFile);
|
||||||
|
DWORD GetFileCRC32(const char* c_szFileName);
|
||||||
|
DWORD GetFileSize(const char* c_szFileName);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
#ifndef __INC_ETERLIB_DEBUG_H__
|
||||||
|
#define __INC_ETERLIB_DEBUG_H__
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
extern void SetLogLevel(UINT uLevel);
|
||||||
|
extern void Log(UINT uLevel, const char* c_szMsg);
|
||||||
|
extern void Logn(UINT uLevel, const char* c_szMsg);
|
||||||
|
extern void Logf(UINT uLevel, const char* c_szFormat, ...);
|
||||||
|
extern void Lognf(UINT uLevel, const char* c_szFormat, ...);
|
||||||
|
|
||||||
|
extern void Trace(const char* c_szMsg);
|
||||||
|
extern void Tracen(const char* c_szMsg);
|
||||||
|
extern void Tracenf(const char* c_szFormat, ...);
|
||||||
|
extern void Tracef(const char* c_szFormat, ...);
|
||||||
|
extern void TraceError(const char* c_szFormat, ...);
|
||||||
|
extern void TraceErrorWithoutEnter(const char* c_szFormat, ...);
|
||||||
|
|
||||||
|
extern void LogBox(const char* c_szMsg, const char * c_szCaption = NULL, HWND hWnd = NULL);
|
||||||
|
extern void LogBoxf(const char* c_szMsg, ...);
|
||||||
|
|
||||||
|
extern void LogFile(const char* c_szMsg);
|
||||||
|
extern void LogFilef(const char * c_szMessage, ...);
|
||||||
|
extern void OpenConsoleWindow(void);
|
||||||
|
extern void CloseConsoleWindow();
|
||||||
|
extern void SetupLog(void);
|
||||||
|
|
||||||
|
extern void OpenLogFile(bool bUseLogFile = true);
|
||||||
|
extern void CloseLogFile();
|
||||||
|
|
||||||
|
extern HWND g_PopupHwnd;
|
||||||
|
|
||||||
|
#define CHECK_RETURN(flag, string) \
|
||||||
|
if (flag) \
|
||||||
|
{ \
|
||||||
|
LogBox(string); \
|
||||||
|
return; \
|
||||||
|
} \
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
#ifndef __INC_ETERBASE_FILEBASE_H__
|
||||||
|
#define __INC_ETERBASE_FILEBASE_H__
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
class CFileBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum EFileMode
|
||||||
|
{
|
||||||
|
FILEMODE_READ = (1 << 0),
|
||||||
|
FILEMODE_WRITE = (1 << 1)
|
||||||
|
};
|
||||||
|
|
||||||
|
CFileBase();
|
||||||
|
virtual ~CFileBase();
|
||||||
|
|
||||||
|
void Destroy();
|
||||||
|
void Close();
|
||||||
|
|
||||||
|
BOOL Create(const char* filename, EFileMode mode);
|
||||||
|
DWORD Size();
|
||||||
|
void SeekCur(DWORD size);
|
||||||
|
void Seek(DWORD offset);
|
||||||
|
DWORD GetPosition();
|
||||||
|
|
||||||
|
virtual BOOL Write(const void* src, int bytes);
|
||||||
|
BOOL Read(void* dest, int bytes);
|
||||||
|
|
||||||
|
char* GetFileName();
|
||||||
|
BOOL IsNull();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int m_mode;
|
||||||
|
char m_filename[MAX_PATH+1];
|
||||||
|
HANDLE m_hFile;
|
||||||
|
DWORD m_dwSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#pragma warning(disable:4786) // character 255 넘어가는거 끄기
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
#include "Stl.h"
|
||||||
|
|
||||||
|
class CMemoryTextFileLoader
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CMemoryTextFileLoader();
|
||||||
|
virtual ~CMemoryTextFileLoader();
|
||||||
|
|
||||||
|
void Bind(int bufSize, const void* c_pvBuf);
|
||||||
|
DWORD GetLineCount();
|
||||||
|
bool CheckLineIndex(DWORD dwLine);
|
||||||
|
bool SplitLine(DWORD dwLine, CTokenVector * pstTokenVector, const char * c_szDelimeter = " \t");
|
||||||
|
int SplitLine2(DWORD dwLine, CTokenVector * pstTokenVector, const char * c_szDelimeter = " \t");
|
||||||
|
bool SplitLineByTab(DWORD dwLine, CTokenVector* pstTokenVector);
|
||||||
|
const std::string & GetLineString(DWORD dwLine);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::vector<std::string> m_stLineVector;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CMemoryFileLoader
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CMemoryFileLoader(int size, const void * c_pvMemoryFile);
|
||||||
|
virtual ~CMemoryFileLoader();
|
||||||
|
|
||||||
|
bool Read(int size, void* pvDst);
|
||||||
|
|
||||||
|
int GetPosition();
|
||||||
|
int GetSize();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool IsReadableSize(int size);
|
||||||
|
const char * GetCurrentPositionPointer();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
const char * m_pcBase;
|
||||||
|
int m_size;
|
||||||
|
int m_pos;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
class CDiskFileLoader
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CDiskFileLoader();
|
||||||
|
virtual ~CDiskFileLoader();
|
||||||
|
|
||||||
|
void Close();
|
||||||
|
bool Open(const char * c_szFileName);
|
||||||
|
bool Read(int size, void * pvDst);
|
||||||
|
|
||||||
|
int GetSize();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void Initialize();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
FILE * m_fp;
|
||||||
|
int m_size;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::map<std::string, std::string> TStringMap;
|
||||||
@@ -0,0 +1,254 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
// CFilename Class
|
||||||
|
//
|
||||||
|
// (c) 2003 IDV, Inc.
|
||||||
|
//
|
||||||
|
// *** INTERACTIVE DATA VISUALIZATION (IDV) PROPRIETARY INFORMATION ***
|
||||||
|
//
|
||||||
|
// This software is supplied under the terms of a license agreement or
|
||||||
|
// nondisclosure agreement with Interactive Data Visualization and may
|
||||||
|
// not be copied or disclosed except in accordance with the terms of
|
||||||
|
// that agreement.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2001-2003 IDV, Inc.
|
||||||
|
// All Rights Reserved.
|
||||||
|
//
|
||||||
|
// IDV, Inc.
|
||||||
|
// 1233 Washington St. Suite 610
|
||||||
|
// Columbia, SC 29201
|
||||||
|
// Voice: (803) 799-1699
|
||||||
|
// Fax: (803) 931-0320
|
||||||
|
// Web: http://www.idvinc.com
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
// CFilename Class
|
||||||
|
|
||||||
|
//class CFilename
|
||||||
|
//{
|
||||||
|
// public:
|
||||||
|
// CFilename() { }
|
||||||
|
// CFilename(const char* pFilename) { m_sRaw = pFilename; }
|
||||||
|
// CFilename(std::string strFilename) { m_sRaw = strFilename; }
|
||||||
|
//
|
||||||
|
// virtual ~CFilename() {}
|
||||||
|
//
|
||||||
|
// operator const std::string() const { return m_sRaw; }
|
||||||
|
// operator std::string&() { return m_sRaw; }
|
||||||
|
// CFilename& operator =(const CFilename& r) { m_sRaw = r.m_sRaw; return *this; }
|
||||||
|
// bool operator ==(const CFilename& r) const { return m_sRaw == r.m_sRaw; }
|
||||||
|
// CFilename operator +(const CFilename& r) const { return CFilename(m_sRaw + r.m_sRaw); }
|
||||||
|
// CFilename& operator +=(const CFilename& r) { m_sRaw += r.m_sRaw; return *this; }
|
||||||
|
// const char& operator[](size_t nIdx) const { return m_sRaw[nIdx]; }
|
||||||
|
// const char* c_str() const { return m_sRaw.c_str(); }
|
||||||
|
// size_t find(const char* pcszSrc) const { return m_sRaw.find(pcszSrc); }
|
||||||
|
// bool empty() const { return m_sRaw.empty(); }
|
||||||
|
// size_t size() const { return m_sRaw.size(); }
|
||||||
|
// size_t length() const { return m_sRaw.length(); }
|
||||||
|
//
|
||||||
|
// string& GetString() { return m_sRaw; }
|
||||||
|
//
|
||||||
|
// void ChangeDosPath()
|
||||||
|
// {
|
||||||
|
// size_t nLength = m_sRaw.length();
|
||||||
|
//
|
||||||
|
// for (size_t i = 0; i < nLength; ++i)
|
||||||
|
// {
|
||||||
|
// if (m_sRaw.at(i) == '/')
|
||||||
|
// m_sRaw.at(i) = '\\';
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// void std::stringPath()
|
||||||
|
// {
|
||||||
|
// size_t nLength = m_sRaw.length();
|
||||||
|
//
|
||||||
|
// for (size_t i = 0; i<nLength; ++i)
|
||||||
|
// {
|
||||||
|
// if (m_sRaw.at(i) == '\\')
|
||||||
|
// m_sRaw.at(i) = '/';
|
||||||
|
// else
|
||||||
|
// m_sRaw.at(i) = (char)tolower(m_sRaw.at(i));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// CFilename GetName(void); // if filename is "/idv/code/file.cpp", it returns "file"
|
||||||
|
// CFilename GetExtension(void); // if filename is "/idv/code/file.cpp", it returns "cpp"
|
||||||
|
// CFilename GetPath(void); // if filename is "/idv/code/file.cpp", it returns "/idv/code"
|
||||||
|
// CFilename NoExtension(void); // if filename is "/idv/code/file.cpp", it returns "/idv/code/file"
|
||||||
|
// CFilename NoPath(void); // if filename is "/idv/code/file.cpp", it returns "file.cpp"
|
||||||
|
// string m_sRaw;
|
||||||
|
//};
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
// CFileNameHelper Class
|
||||||
|
|
||||||
|
class CFileNameHelper
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void ChangeDosPath(std::string& str) {
|
||||||
|
size_t nLength = str.length();
|
||||||
|
|
||||||
|
for (size_t i = 0; i < nLength; ++i)
|
||||||
|
{
|
||||||
|
if (str.at(i) == '/')
|
||||||
|
str.at(i) = '\\';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void StringPath(std::string& str) {
|
||||||
|
size_t nLength = str.length();
|
||||||
|
|
||||||
|
for (size_t i = 0; i<nLength; ++i)
|
||||||
|
{
|
||||||
|
if (str.at(i) == '\\')
|
||||||
|
str.at(i) = '/';
|
||||||
|
else
|
||||||
|
str.at(i) = (char)tolower(str.at(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string GetName(std::string& str); // if filename is "/idv/code/file.cpp", it returns "file"
|
||||||
|
static std::string GetExtension(std::string& str); // if filename is "/idv/code/file.cpp", it returns "cpp"
|
||||||
|
static std::string GetPath(std::string& str); // if filename is "/idv/code/file.cpp", it returns "/idv/code"
|
||||||
|
static std::string NoExtension(std::string& str); // if filename is "/idv/code/file.cpp", it returns "/idv/code/file"
|
||||||
|
static std::string NoPath(std::string& str); // if filename is "/idv/code/file.cpp", it returns "file.cpp"
|
||||||
|
};
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
// CFileNameHelper::GetExtension
|
||||||
|
|
||||||
|
inline std::string CFileNameHelper::GetName(std::string& str)
|
||||||
|
{
|
||||||
|
std::string strName;
|
||||||
|
|
||||||
|
size_t nLength = str.length();
|
||||||
|
|
||||||
|
if (nLength > 0)
|
||||||
|
{
|
||||||
|
size_t iExtensionStartPos = nLength - 1;
|
||||||
|
|
||||||
|
for (size_t i = nLength - 1; i > 0; i--)
|
||||||
|
{
|
||||||
|
if (str[i] == '.')
|
||||||
|
{
|
||||||
|
iExtensionStartPos = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (str[i] == '/')
|
||||||
|
{
|
||||||
|
strName = std::string(str.c_str() + i + 1);
|
||||||
|
strName.resize(iExtensionStartPos - i - 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return strName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
// CFilenameHelper::GetExtension
|
||||||
|
|
||||||
|
inline std::string CFileNameHelper::GetExtension(std::string& str)
|
||||||
|
{
|
||||||
|
std::string strExtension;
|
||||||
|
|
||||||
|
size_t nLength = str.length();
|
||||||
|
|
||||||
|
if (nLength > 0)
|
||||||
|
{
|
||||||
|
for (size_t i = nLength - 1; i > 0 && str[i] != '/'; i--)
|
||||||
|
if (str[i] == '.')
|
||||||
|
{
|
||||||
|
strExtension = std::string(str.c_str( ) + i + 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return strExtension;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
// CFilenameHelper::GetPath
|
||||||
|
|
||||||
|
inline std::string CFileNameHelper::GetPath(std::string& str)
|
||||||
|
{
|
||||||
|
char szPath[1024];
|
||||||
|
szPath[0] = '\0';
|
||||||
|
|
||||||
|
size_t nLength = str.length();
|
||||||
|
|
||||||
|
if (nLength > 0)
|
||||||
|
{
|
||||||
|
for (size_t i = nLength - 1; i > 0; i--)
|
||||||
|
{
|
||||||
|
if (str[i] == '/' || str[i] == '\\')
|
||||||
|
{
|
||||||
|
for (size_t j = 0; j < i + 1; j++)
|
||||||
|
szPath[j] = str[j];
|
||||||
|
szPath[i+1] = '\0';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 == i)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return szPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
// CFilenameHelper::NoExtension
|
||||||
|
|
||||||
|
inline std::string CFileNameHelper::NoExtension(std::string& str)
|
||||||
|
{
|
||||||
|
std::size_t npos = str.find_last_of('.');
|
||||||
|
|
||||||
|
if (std::string::npos != npos)
|
||||||
|
return std::string(str, 0, npos);
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
// CFilenameHelper::NoPath
|
||||||
|
|
||||||
|
inline std::string CFileNameHelper::NoPath(std::string& str)
|
||||||
|
{
|
||||||
|
char szPath[1024];
|
||||||
|
szPath[0] = '\0';
|
||||||
|
|
||||||
|
size_t nLength = str.length();
|
||||||
|
|
||||||
|
if (nLength > 0)
|
||||||
|
{
|
||||||
|
strcpy(szPath, str.c_str());
|
||||||
|
|
||||||
|
for (size_t i = nLength - 1; i > 0; i--)
|
||||||
|
{
|
||||||
|
if (str[i] == '/' || str[i] == '\\')
|
||||||
|
{
|
||||||
|
int k = 0;
|
||||||
|
for (size_t j = i + 1; j < nLength; j++, k++)
|
||||||
|
szPath[k] = str[j];
|
||||||
|
szPath[k] = '\0';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 == i)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return szPath;
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
#ifndef __INC_MAPPEDFILE_H__
|
||||||
|
#define __INC_MAPPEDFILE_H__
|
||||||
|
|
||||||
|
#include "lzo.h"
|
||||||
|
#include "FileBase.h"
|
||||||
|
|
||||||
|
class CMappedFile : public CFileBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum ESeekType
|
||||||
|
{
|
||||||
|
SEEK_TYPE_BEGIN,
|
||||||
|
SEEK_TYPE_CURRENT,
|
||||||
|
SEEK_TYPE_END
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
CMappedFile();
|
||||||
|
virtual ~CMappedFile();
|
||||||
|
|
||||||
|
void Link(DWORD dwBufSize, const void* c_pvBufData);
|
||||||
|
|
||||||
|
BOOL Create(const char* filename);
|
||||||
|
BOOL Create(const char* filename, const void** dest, int offset, int size);
|
||||||
|
LPCVOID Get();
|
||||||
|
void Destroy();
|
||||||
|
int Seek(DWORD offset, int iSeekType = SEEK_TYPE_BEGIN);
|
||||||
|
int Map(const void **dest, int offset=0, int size=0);
|
||||||
|
DWORD Size();
|
||||||
|
DWORD GetPosition();
|
||||||
|
BOOL Read(void* dest, int bytes);
|
||||||
|
DWORD GetSeekPosition();
|
||||||
|
void BindLZObject(CLZObject * pLZObj);
|
||||||
|
void BindLZObjectWithBufferedSize(CLZObject * pLZObj);
|
||||||
|
BYTE* AppendDataBlock( const void* pBlock, DWORD dwBlockSize );
|
||||||
|
|
||||||
|
BYTE * GetCurrentSeekPoint();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void Unmap(LPCVOID data);
|
||||||
|
|
||||||
|
private:
|
||||||
|
BYTE* m_pbBufLinkData;
|
||||||
|
DWORD m_dwBufLinkSize;
|
||||||
|
|
||||||
|
BYTE* m_pbAppendResultDataBlock;
|
||||||
|
DWORD m_dwAppendResultDataSize;
|
||||||
|
|
||||||
|
DWORD m_seekPosition;
|
||||||
|
HANDLE m_hFM;
|
||||||
|
DWORD m_dataOffset;
|
||||||
|
DWORD m_mapSize;
|
||||||
|
LPVOID m_lpMapData;
|
||||||
|
LPVOID m_lpData;
|
||||||
|
|
||||||
|
CLZObject * m_pLZObj;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#ifndef __INC_ETERBASE_RANDOM_H__
|
||||||
|
#define __INC_ETERBASE_RANDOM_H__
|
||||||
|
|
||||||
|
// PORT: POSIX <stdlib.h> declares its own srandom()/random(); keep the 40250 generator under
|
||||||
|
// linker-distinct names (stdlib first, so its include guard keeps it from seeing the macros).
|
||||||
|
#include <stdlib.h>
|
||||||
|
#define srandom eterbase_srandom
|
||||||
|
#define random eterbase_random
|
||||||
|
|
||||||
|
extern void srandom(unsigned long seed);
|
||||||
|
extern unsigned long random();
|
||||||
|
extern float frandom(float flLow, float flHigh);
|
||||||
|
extern long random_range(long from, long to);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#ifndef _EL_SERVICEDEFS_H_
|
||||||
|
#define _EL_SERVICEDEFS_H_
|
||||||
|
|
||||||
|
#define _IMPROVED_PACKET_ENCRYPTION_
|
||||||
|
|
||||||
|
#endif //_EL_SERVICEDEFS_H_
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
#ifndef __INC_ETERLIB_SINGLETON_H__
|
||||||
|
#define __INC_ETERLIB_SINGLETON_H__
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdint.h> // PORT: intptr_t for the offset below
|
||||||
|
|
||||||
|
template <typename T> class CSingleton
|
||||||
|
{
|
||||||
|
static T * ms_singleton;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CSingleton()
|
||||||
|
{
|
||||||
|
assert(!ms_singleton);
|
||||||
|
// PORT: was (int) casts (ILP32 Win32); intptr_t keeps the pointer width on 64-bit targets.
|
||||||
|
intptr_t offset = (intptr_t) (T*) 1 - (intptr_t) (CSingleton <T>*) (T*) 1;
|
||||||
|
ms_singleton = (T*) ((intptr_t) this + offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~CSingleton()
|
||||||
|
{
|
||||||
|
assert(ms_singleton);
|
||||||
|
ms_singleton = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
__forceinline static T & Instance()
|
||||||
|
{
|
||||||
|
assert(ms_singleton);
|
||||||
|
return (*ms_singleton);
|
||||||
|
}
|
||||||
|
|
||||||
|
__forceinline static T * InstancePtr()
|
||||||
|
{
|
||||||
|
return (ms_singleton);
|
||||||
|
}
|
||||||
|
|
||||||
|
__forceinline static T & instance()
|
||||||
|
{
|
||||||
|
assert(ms_singleton);
|
||||||
|
return (*ms_singleton);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T> T * CSingleton <T>::ms_singleton = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// singleton for non-hungarian
|
||||||
|
//
|
||||||
|
template <typename T> class singleton
|
||||||
|
{
|
||||||
|
static T * ms_singleton;
|
||||||
|
|
||||||
|
public:
|
||||||
|
singleton()
|
||||||
|
{
|
||||||
|
assert(!ms_singleton);
|
||||||
|
int offset = (int) (T*) 1 - (int) (singleton <T>*) (T*) 1;
|
||||||
|
ms_singleton = (T*) ((int) this + offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~singleton()
|
||||||
|
{
|
||||||
|
assert(ms_singleton);
|
||||||
|
ms_singleton = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
__forceinline static T & Instance()
|
||||||
|
{
|
||||||
|
assert(ms_singleton);
|
||||||
|
return (*ms_singleton);
|
||||||
|
}
|
||||||
|
|
||||||
|
__forceinline static T * InstancePtr()
|
||||||
|
{
|
||||||
|
return (ms_singleton);
|
||||||
|
}
|
||||||
|
|
||||||
|
__forceinline static T & instance()
|
||||||
|
{
|
||||||
|
assert(ms_singleton);
|
||||||
|
return (*ms_singleton);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T> T * singleton <T>::ms_singleton = 0;
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||||
|
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||||
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#pragma warning(disable:4710) // not inlined
|
||||||
|
#pragma warning(disable:4786) // character 255 넘어가는거 끄기
|
||||||
|
#pragma warning(disable:4244) // type conversion possible lose of data
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#pragma warning ( disable : 4201 )
|
||||||
|
#include <mmsystem.h>
|
||||||
|
#pragma warning ( default : 4201 )
|
||||||
|
#include <imagehlp.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#pragma warning ( push, 3 )
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <deque>
|
||||||
|
#include <list>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
#pragma warning ( pop )
|
||||||
|
|
||||||
|
#if _MSC_VER >= 1400
|
||||||
|
#define stricmp _stricmp
|
||||||
|
#define strnicmp _strnicmp
|
||||||
|
#define strupt _strupr
|
||||||
|
#define strcmpi _strcmpi
|
||||||
|
#define fileno _fileno
|
||||||
|
//#define access _access_s
|
||||||
|
//#define _access _access_s
|
||||||
|
#define atoi _atoi64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Armadillo nanomite protection
|
||||||
|
#ifndef NANOBEGIN
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
#define NANOBEGIN __emit__ (0xEB,0x03,0xD6,0xD7,0x01)
|
||||||
|
#define NANOEND __emit__ (0xEB,0x03,0xD6,0xD7,0x00)
|
||||||
|
#else
|
||||||
|
#define NANOBEGIN __asm _emit 0xEB __asm _emit 0x03 __asm _emit 0xD6 __asm _emit 0xD7 __asm _emit 0x01
|
||||||
|
#define NANOEND __asm _emit 0xEB __asm _emit 0x03 __asm _emit 0xD6 __asm _emit 0xD7 __asm _emit 0x00
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "vk.h"
|
||||||
|
#include "Filename.h"
|
||||||
|
#include "ServiceDefs.h"
|
||||||
@@ -0,0 +1,444 @@
|
|||||||
|
#ifndef __INC_ETERBASE_STL_H__
|
||||||
|
#define __INC_ETERBASE_STL_H__
|
||||||
|
|
||||||
|
#pragma warning(disable:4786) // identifier was truncated to '255' characters in the browser information
|
||||||
|
#pragma warning(disable:4018) // signed <-> unsigned mismatch
|
||||||
|
#pragma warning(disable:4503) // decorated name length exceeded, name was truncated
|
||||||
|
#pragma warning(disable:4018) // '<' : signed/unsigned mismatch
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#pragma warning ( push, 3 )
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <stack>
|
||||||
|
#include <deque>
|
||||||
|
#include <list>
|
||||||
|
#include <set>
|
||||||
|
#include <map>
|
||||||
|
#include <queue>
|
||||||
|
#include <functional>
|
||||||
|
#include <sstream> // PORT: was <SSTREAM> (case-insensitive file system)
|
||||||
|
|
||||||
|
#pragma warning ( pop )
|
||||||
|
|
||||||
|
extern char korean_tolower(const char c);
|
||||||
|
extern std::string& stl_static_string(const char* c_sz);
|
||||||
|
extern void stl_lowers(std::string& rstRet);
|
||||||
|
extern int split_string(const std::string & input, const std::string & delimiter, std::vector<std::string>& results, bool includeEmpties);
|
||||||
|
|
||||||
|
struct stl_sz_less
|
||||||
|
{
|
||||||
|
bool operator() (char * const & left, char * const & right) const
|
||||||
|
{
|
||||||
|
return (strcmp(left, right) < 0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename TContainer>
|
||||||
|
inline void stl_wipe(TContainer& container)
|
||||||
|
{
|
||||||
|
for (auto i = container.begin(); i != container.end(); ++i)
|
||||||
|
{
|
||||||
|
delete *i;
|
||||||
|
*i = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
container.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename TString>
|
||||||
|
inline int hex2dec(TString szhex)
|
||||||
|
{
|
||||||
|
int hex0 = toupper(szhex[0]);
|
||||||
|
int hex1 = toupper(szhex[1]);
|
||||||
|
|
||||||
|
return (hex1 >= 'A' ? hex1 - 'A' + 10 : hex1 - '0') +
|
||||||
|
(hex0 >= 'A' ? hex0 - 'A' + 10 : hex0 - '0') * 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename TString>
|
||||||
|
inline unsigned long htmlColorStringToARGB(TString str)
|
||||||
|
{
|
||||||
|
unsigned long alp = hex2dec(str);
|
||||||
|
unsigned long red = hex2dec(str + 2);
|
||||||
|
unsigned long green = hex2dec(str + 4);
|
||||||
|
unsigned long blue = hex2dec(str + 6);
|
||||||
|
return (alp << 24 | red << 16 | green << 8 | blue);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename TContainer>
|
||||||
|
inline void stl_wipe_second(TContainer& container)
|
||||||
|
{
|
||||||
|
for (auto i = container.begin(); i != container.end(); ++i)
|
||||||
|
{
|
||||||
|
delete i->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
container.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline void safe_release(T& rpObject)
|
||||||
|
{
|
||||||
|
if (!rpObject)
|
||||||
|
return;
|
||||||
|
|
||||||
|
rpObject->Release();
|
||||||
|
rpObject = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void DeleteVectorItem(std::vector<T> * pVector, unsigned long dwIndex)
|
||||||
|
{
|
||||||
|
if (dwIndex >= pVector->size())
|
||||||
|
{
|
||||||
|
assert(!"Wrong index to delete!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (1 == pVector->size())
|
||||||
|
{
|
||||||
|
pVector->clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto itor = pVector->begin();
|
||||||
|
for (unsigned long i = 0; i < dwIndex; ++i)
|
||||||
|
++itor;
|
||||||
|
|
||||||
|
pVector->erase(itor);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void DeleteVectorItem(T * pVector, unsigned long dwStartIndex, unsigned long dwEndIndex)
|
||||||
|
{
|
||||||
|
if (dwStartIndex >= pVector->size())
|
||||||
|
{
|
||||||
|
assert(!"Wrong start index to delete!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (dwEndIndex >= pVector->size())
|
||||||
|
{
|
||||||
|
assert(!"Wrong end index to delete!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto itorStart = pVector->begin();
|
||||||
|
for (unsigned long i = 0; i < dwStartIndex; ++i)
|
||||||
|
++itorStart;
|
||||||
|
auto itorEnd = pVector->begin();
|
||||||
|
for (unsigned long j = 0; j < dwEndIndex; ++j)
|
||||||
|
++itorEnd;
|
||||||
|
|
||||||
|
pVector->erase(itorStart, itorEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void DeleteVectorItem(std::vector<T> * pVector, T pItem)
|
||||||
|
{
|
||||||
|
auto itor = pVector->begin();
|
||||||
|
for (; itor != pVector->end(); ++itor)
|
||||||
|
{
|
||||||
|
if (pItem == *itor)
|
||||||
|
{
|
||||||
|
if (1 == pVector->size())
|
||||||
|
{
|
||||||
|
pVector->clear();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pVector->erase(itor);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void DeleteListItem(std::list<T> * pList, T pItem)
|
||||||
|
{
|
||||||
|
auto itor = pList->begin();
|
||||||
|
for (; itor != pList->end(); ++itor)
|
||||||
|
{
|
||||||
|
if (pItem == *itor)
|
||||||
|
{
|
||||||
|
if (1 == pList->size())
|
||||||
|
{
|
||||||
|
pList->clear();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pList->erase(itor);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename F>
|
||||||
|
void stl_vector_qsort(std::vector<T>& rdataVector, F comp)
|
||||||
|
{
|
||||||
|
if (rdataVector.empty()) return;
|
||||||
|
qsort(&rdataVector[0], rdataVector.size(), sizeof(T), comp);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename TData>
|
||||||
|
class stl_stack_pool
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
stl_stack_pool()
|
||||||
|
{
|
||||||
|
m_pos = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
stl_stack_pool(int capacity)
|
||||||
|
{
|
||||||
|
m_pos = 0;
|
||||||
|
initialize(capacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~stl_stack_pool()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void initialize(int capacity)
|
||||||
|
{
|
||||||
|
m_dataVector.clear();
|
||||||
|
m_dataVector.resize(capacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
void clear()
|
||||||
|
{
|
||||||
|
m_pos = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
TData * alloc()
|
||||||
|
{
|
||||||
|
assert(!m_dataVector.empty() && "stl_stack_pool::alloc you MUST run stl_stack_pool::initialize");
|
||||||
|
|
||||||
|
int max = m_dataVector.size();
|
||||||
|
|
||||||
|
if (m_pos >= max)
|
||||||
|
{
|
||||||
|
assert(!"stl_stack_pool::alloc OUT of memory");
|
||||||
|
m_pos = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return &m_dataVector[m_pos++];
|
||||||
|
}
|
||||||
|
|
||||||
|
TData* base()
|
||||||
|
{
|
||||||
|
return &m_dataVector[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
int size()
|
||||||
|
{
|
||||||
|
return m_pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_pos;
|
||||||
|
|
||||||
|
std::vector<TData> m_dataVector;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename TData, typename THandle=int>
|
||||||
|
class stl_circle_pool
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef bool TFlag;
|
||||||
|
|
||||||
|
public:
|
||||||
|
stl_circle_pool()
|
||||||
|
{
|
||||||
|
initialize();
|
||||||
|
}
|
||||||
|
virtual ~stl_circle_pool()
|
||||||
|
{
|
||||||
|
destroy();
|
||||||
|
}
|
||||||
|
void destroy()
|
||||||
|
{
|
||||||
|
if (m_datas)
|
||||||
|
{
|
||||||
|
delete [] m_datas;
|
||||||
|
m_datas=NULL;
|
||||||
|
}
|
||||||
|
if (m_flags)
|
||||||
|
{
|
||||||
|
delete [] m_flags;
|
||||||
|
m_flags=NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void create(int size)
|
||||||
|
{
|
||||||
|
destroy();
|
||||||
|
|
||||||
|
initialize();
|
||||||
|
|
||||||
|
m_size=size;
|
||||||
|
m_datas=new TData[m_size];
|
||||||
|
m_flags=new TFlag[m_size];
|
||||||
|
|
||||||
|
for (int i=0; i<m_size; ++i)
|
||||||
|
m_flags[i]=false;
|
||||||
|
}
|
||||||
|
THandle alloc()
|
||||||
|
{
|
||||||
|
THandle max=m_size;
|
||||||
|
|
||||||
|
THandle loop=max;
|
||||||
|
while (loop--)
|
||||||
|
{
|
||||||
|
int cur=m_pos%max;++m_pos;
|
||||||
|
if (!m_flags[cur])
|
||||||
|
{
|
||||||
|
m_flags[cur]=true;
|
||||||
|
return cur;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(!"Out of Memory");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
void free(THandle handle)
|
||||||
|
{
|
||||||
|
assert(check(handle) && "Out of RANGE");
|
||||||
|
m_flags[handle]=false;
|
||||||
|
}
|
||||||
|
inline bool check(THandle handle)
|
||||||
|
{
|
||||||
|
if (handle>=m_size) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
inline int size()
|
||||||
|
{
|
||||||
|
return m_size;
|
||||||
|
}
|
||||||
|
inline TData& refer(THandle handle)
|
||||||
|
{
|
||||||
|
assert(check(handle) && "Out of RANGE");
|
||||||
|
return m_datas[handle];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void initialize()
|
||||||
|
{
|
||||||
|
m_datas=NULL;
|
||||||
|
m_flags=NULL;
|
||||||
|
m_pos=0;
|
||||||
|
m_size=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
TData* m_datas;
|
||||||
|
TFlag* m_flags;
|
||||||
|
|
||||||
|
THandle m_size;
|
||||||
|
|
||||||
|
THandle m_pos;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::vector<std::string> CTokenVector;
|
||||||
|
typedef std::map<std::string, std::string> CTokenMap;
|
||||||
|
typedef std::map<std::string, CTokenVector> CTokenVectorMap;
|
||||||
|
|
||||||
|
//class CTokenVector : public std::vector<std::string>
|
||||||
|
//{
|
||||||
|
// public:
|
||||||
|
// CTokenVector() : std::vector<std::string> ()
|
||||||
|
// {
|
||||||
|
// }
|
||||||
|
// virtual ~CTokenVector()
|
||||||
|
// {
|
||||||
|
// }
|
||||||
|
//};
|
||||||
|
//
|
||||||
|
//class CTokenMap : public std::map<std::string, std::string>
|
||||||
|
//{
|
||||||
|
// public:
|
||||||
|
// CTokenMap() : std::map<std::string, std::string>()
|
||||||
|
// {
|
||||||
|
// }
|
||||||
|
// virtual ~CTokenMap()
|
||||||
|
// {
|
||||||
|
// }
|
||||||
|
//};
|
||||||
|
//
|
||||||
|
//class CTokenVectorMap : public std::map<std::string, CTokenVector>
|
||||||
|
//{
|
||||||
|
// public:
|
||||||
|
// CTokenVectorMap() : std::map<std::string, CTokenVector>()
|
||||||
|
// {
|
||||||
|
// }
|
||||||
|
// virtual ~CTokenVectorMap()
|
||||||
|
// {
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//};
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
template <typename T1, typename T2>
|
||||||
|
class CMapIterator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef std::map<T1, T2> TMapType;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CMapIterator(TMapType & rMap)
|
||||||
|
{
|
||||||
|
m_it = rMap.begin();
|
||||||
|
m_itEnd = rMap.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline T2 operator * () { return m_it->second; }
|
||||||
|
|
||||||
|
inline bool operator ++()
|
||||||
|
{
|
||||||
|
if (m_itEnd == m_it)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
++m_it;
|
||||||
|
return m_itEnd != m_it;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline T1 GetFirst() { return m_it->first; }
|
||||||
|
inline T2 GetSecond() { return m_it->second; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
TMapType::iterator m_it;
|
||||||
|
TMapType::iterator m_itEnd;
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct stringhash
|
||||||
|
{
|
||||||
|
size_t GetHash(const std::string & str) const
|
||||||
|
{
|
||||||
|
const unsigned char * s = (const unsigned char*) str.c_str();
|
||||||
|
const unsigned char * end = s + str.size();
|
||||||
|
size_t h = 0;
|
||||||
|
|
||||||
|
while (s < end)
|
||||||
|
{
|
||||||
|
h *= 16777619;
|
||||||
|
h ^= (unsigned char) *(unsigned char *) (s++);
|
||||||
|
}
|
||||||
|
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t operator () (const std::string & str) const
|
||||||
|
{
|
||||||
|
return GetHash(str);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include "Singleton.h"
|
||||||
|
|
||||||
|
class CTimer : public CSingleton<CTimer>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CTimer();
|
||||||
|
virtual ~CTimer();
|
||||||
|
|
||||||
|
void Advance();
|
||||||
|
void Adjust(int iTimeGap);
|
||||||
|
void SetBaseTime();
|
||||||
|
|
||||||
|
float GetCurrentSecond();
|
||||||
|
DWORD GetCurrentMillisecond();
|
||||||
|
|
||||||
|
float GetElapsedSecond();
|
||||||
|
DWORD GetElapsedMilliecond();
|
||||||
|
|
||||||
|
void UseCustomTime();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool m_bUseRealTime;
|
||||||
|
DWORD m_dwBaseTime;
|
||||||
|
DWORD m_dwCurrentTime;
|
||||||
|
float m_fCurrentTime;
|
||||||
|
DWORD m_dwElapsedTime;
|
||||||
|
int m_index;
|
||||||
|
};
|
||||||
|
|
||||||
|
BOOL ELTimer_Init();
|
||||||
|
|
||||||
|
DWORD ELTimer_GetMSec();
|
||||||
|
|
||||||
|
VOID ELTimer_SetServerMSec(DWORD dwServerTime);
|
||||||
|
DWORD ELTimer_GetServerMSec();
|
||||||
|
|
||||||
|
VOID ELTimer_SetFrameMSec();
|
||||||
|
DWORD ELTimer_GetFrameMSec();
|
||||||
@@ -0,0 +1,219 @@
|
|||||||
|
#ifndef __INC_ETER2_ETERBASE_UTILS_H__
|
||||||
|
#define __INC_ETER2_ETERBASE_UTILS_H__
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <math.h> // PORT: sin/cos below; MSVC's <windows.h>/<string> pulled it in transitively
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#ifndef SAFE_DELETE
|
||||||
|
#define SAFE_DELETE(p) { if (p) { delete (p); (p) = NULL; } }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SAFE_DELETE_ARRAY
|
||||||
|
#define SAFE_DELETE_ARRAY(p) { if (p) { delete[] (p); (p) = NULL; } }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SAFE_RELEASE
|
||||||
|
#define SAFE_RELEASE(p) { if (p) { (p)->Release(); (p) = NULL; } }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SAFE_FREE_GLOBAL
|
||||||
|
#define SAFE_FREE_GLOBAL(p) { if (p) { ::GlobalFree(p); (p) = NULL; } }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SAFE_FREE_LIBRARY
|
||||||
|
#define SAFE_FREE_LIBRARY(p) { if (p) { ::FreeLibrary(p); (p) = NULL; } }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define AssertLog(str) TraceError(str); assert(!str)
|
||||||
|
|
||||||
|
#ifndef MAKEFOURCC
|
||||||
|
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
|
||||||
|
((DWORD)(BYTE) (ch0 ) | ((DWORD)(BYTE) (ch1) << 8) | \
|
||||||
|
((DWORD)(BYTE) (ch2) << 16) | ((DWORD)(BYTE) (ch3) << 24))
|
||||||
|
#endif // defined(MAKEFOURCC)
|
||||||
|
|
||||||
|
#ifndef IS_SET
|
||||||
|
#define IS_SET(flag,bit) ((flag) & (bit))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SET_BIT
|
||||||
|
#define SET_BIT(var,bit) ((var) |= (bit))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef REMOVE_BIT
|
||||||
|
#define REMOVE_BIT(var,bit) ((var) &= ~(bit))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TOGGLE_BIT
|
||||||
|
#define TOGGLE_BIT(var,bit) ((var) = (var) ^ (bit))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern const char * CreateTempFileName(const char * c_pszPrefix = NULL);
|
||||||
|
extern void GetFilePathNameExtension(const char* c_szFile, int len, std::string* pstPath, std::string* pstName, std::string* pstExt);
|
||||||
|
extern void GetFileExtension(const char* c_szFile, int len, std::string* pstExt);
|
||||||
|
extern void GetFileNameParts(const char* c_szFile, int len, char* pszPath, char* pszName, char* pszExt);
|
||||||
|
extern void GetOldIndexingName(char * szName, int Index);
|
||||||
|
extern void GetIndexingName(char * szName, DWORD Index);
|
||||||
|
extern void stl_lowers(std::string& rstRet);
|
||||||
|
extern void GetOnlyFileName(const char * sz_Name, std::string & strFileName);
|
||||||
|
extern void GetOnlyPathName(const char * sz_Name, std::string & OnlyPathName);
|
||||||
|
extern const char * GetOnlyPathName(const char * c_szName);
|
||||||
|
bool GetLocalFileName(const char * c_szGlobalPath, const char * c_szFullPathFileName, std::string * pstrLocalFileName);
|
||||||
|
extern void GetExceptionPathName(const char * sz_Name, std::string & OnlyFileName);
|
||||||
|
extern void GetWorkingFolder(std::string & strFileName);
|
||||||
|
extern void StringLowers(char * pString);
|
||||||
|
extern void StringPath(std::string & rString);
|
||||||
|
extern void StringPath(char * pString); // 모두 소문자로 만들고, \는 /로 바꾼다.
|
||||||
|
extern void StringPath(const char * c_szSrc, char * szDest); // 모두 소문자로 만들고, \는 /로 바꾼다.
|
||||||
|
extern void StringPath(const char * c_szSrc, std::string & rString); // 모두 소문자로 만들고, \는 /로 바꾼다.
|
||||||
|
extern void PrintAsciiData(const void* data, int bytes);
|
||||||
|
bool IsFile(const char* filename);
|
||||||
|
bool IsGlobalFileName(const char * c_szFileName);
|
||||||
|
int MIN(int a, int b);
|
||||||
|
int MAX(int a, int b);
|
||||||
|
int MINMAX(int min, int value, int max);
|
||||||
|
float fMIN(float a, float b);
|
||||||
|
float fMAX(float a, float b);
|
||||||
|
float fMINMAX(float min, float value, float max);
|
||||||
|
void MyCreateDirectory(const char* path);
|
||||||
|
void RemoveAllDirectory(const char * c_szDirectoryName);
|
||||||
|
bool SplitLine(const char * c_szLine, const char * c_szDelimeter, std::vector<std::string> * pkVec_strToken);
|
||||||
|
const char * _getf(const char* c_szFormat, ...);
|
||||||
|
PCHAR* CommandLineToArgv( PCHAR CmdLine, int* _argc );
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
T EL_DegreeToRadian(T degree)
|
||||||
|
{
|
||||||
|
const T PI = T(3.141592);
|
||||||
|
return T(PI*degree/180.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void ELPlainCoord_GetRotatedPixelPosition(T centerX, T centerY, T distance, T rotDegree, T* pdstX, T* pdstY)
|
||||||
|
{
|
||||||
|
T rotRadian=EL_DegreeToRadian(rotDegree);
|
||||||
|
*pdstX=centerX+distance*T(sin((double)rotRadian));
|
||||||
|
*pdstY=centerY+distance*T(cos((double)rotRadian));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
T EL_SignedDegreeToUnsignedDegree(T fSrc)
|
||||||
|
{
|
||||||
|
if (fSrc<0.0f)
|
||||||
|
return T(360.0+T(fmod(fSrc, 360.0)));
|
||||||
|
|
||||||
|
return T(fmod(fSrc, 360.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
T ELRightCoord_ConvertToPlainCoordDegree(T srcDegree)
|
||||||
|
{
|
||||||
|
return T(fmod(450.0 - srcDegree, 360.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename C>
|
||||||
|
void string_join(const std::string& sep, const C& container, std::string* ret)
|
||||||
|
{
|
||||||
|
unsigned int capacity = sep.length() * container.size() - 1;
|
||||||
|
|
||||||
|
// calculate string sequence
|
||||||
|
{
|
||||||
|
for (auto i = container.begin(); i != container.end(); ++i)
|
||||||
|
capacity += (*i).length();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string buf;
|
||||||
|
buf.reserve(capacity);
|
||||||
|
|
||||||
|
// join strings
|
||||||
|
{
|
||||||
|
auto cur = container.begin();
|
||||||
|
auto end = container.end();
|
||||||
|
--end;
|
||||||
|
|
||||||
|
while (cur != end)
|
||||||
|
{
|
||||||
|
buf.append(*cur++);
|
||||||
|
buf.append(sep);
|
||||||
|
}
|
||||||
|
buf.append(*cur);
|
||||||
|
}
|
||||||
|
|
||||||
|
swap(*ret, buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
__forceinline int htoi(const wchar_t *s, int size)
|
||||||
|
{
|
||||||
|
const wchar_t *t = s;
|
||||||
|
int x = 0, y = 1;
|
||||||
|
s += size;
|
||||||
|
|
||||||
|
while (t <= --s)
|
||||||
|
{
|
||||||
|
if (L'0' <= *s && *s <= L'9')
|
||||||
|
x += y * (*s - L'0');
|
||||||
|
else if (L'a' <= *s && *s <= L'f')
|
||||||
|
x += y * (*s - L'a' + 10);
|
||||||
|
else if (L'A' <= *s && *s <= L'F')
|
||||||
|
x += y * (10 + *s - L'A');
|
||||||
|
else
|
||||||
|
return -1; /* invalid input! */
|
||||||
|
y <<= 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
__forceinline int htoi(const char *s, int size)
|
||||||
|
{
|
||||||
|
const char *t = s;
|
||||||
|
int x = 0, y = 1;
|
||||||
|
s += size;
|
||||||
|
|
||||||
|
while (t <= --s)
|
||||||
|
{
|
||||||
|
if ('0' <= *s && *s <= '9')
|
||||||
|
x += y * (*s - '0');
|
||||||
|
else if ('a' <= *s && *s <= 'f')
|
||||||
|
x += y * (*s - 'a' + 10);
|
||||||
|
else if ('A' <= *s && *s <= 'F')
|
||||||
|
x += y * (10 + *s - 'A');
|
||||||
|
else
|
||||||
|
return -1; /* invalid input! */
|
||||||
|
y <<= 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
__forceinline int htoi(const char *s)
|
||||||
|
{
|
||||||
|
const char *t = s;
|
||||||
|
int x = 0, y = 1;
|
||||||
|
s += strlen(s);
|
||||||
|
|
||||||
|
while (t <= --s)
|
||||||
|
{
|
||||||
|
if ('0' <= *s && *s <= '9')
|
||||||
|
x += y * (*s - '0');
|
||||||
|
else if ('a' <= *s && *s <= 'f')
|
||||||
|
x += y * (*s - 'a' + 10);
|
||||||
|
else if ('A' <= *s && *s <= 'F')
|
||||||
|
x += y * (10 + *s - 'A');
|
||||||
|
else
|
||||||
|
return -1; /* invalid input! */
|
||||||
|
y <<= 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef std::vector<std::string> TTokenVector;
|
||||||
|
|
||||||
|
void StringExceptCharacter(std::string * pstrString, const char * c_szCharacter);
|
||||||
|
|
||||||
|
extern void GetExcutedFileName(std::string & r_str);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
#ifndef __INC_METIN_II_371GNFBQOCJ_LZO_H__
|
||||||
|
#define __INC_METIN_II_371GNFBQOCJ_LZO_H__
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <lzo/lzo1x.h>
|
||||||
|
#include "Singleton.h"
|
||||||
|
|
||||||
|
class CLZObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
#pragma pack(4)
|
||||||
|
typedef struct SHeader
|
||||||
|
{
|
||||||
|
DWORD dwFourCC;
|
||||||
|
DWORD dwEncryptSize; // 암호화된 크기
|
||||||
|
DWORD dwCompressedSize; // 압축된 데이터 크기
|
||||||
|
DWORD dwRealSize; // 실제 데이터 크기
|
||||||
|
} THeader;
|
||||||
|
#pragma pack()
|
||||||
|
|
||||||
|
CLZObject();
|
||||||
|
~CLZObject();
|
||||||
|
|
||||||
|
void Clear();
|
||||||
|
|
||||||
|
void BeginCompress(const void * pvIn, UINT uiInLen);
|
||||||
|
void BeginCompressInBuffer(const void * pvIn, UINT uiInLen, void * pvOut);
|
||||||
|
bool Compress();
|
||||||
|
|
||||||
|
bool BeginDecompress(const void * pvIn);
|
||||||
|
bool Decompress(DWORD * pdwKey = NULL);
|
||||||
|
|
||||||
|
bool Encrypt(DWORD * pdwKey);
|
||||||
|
bool __Decrypt(DWORD * key, BYTE* data);
|
||||||
|
|
||||||
|
const THeader & GetHeader() { return *m_pHeader; }
|
||||||
|
BYTE * GetBuffer() { return m_pbBuffer; }
|
||||||
|
DWORD GetSize();
|
||||||
|
void AllocBuffer(DWORD dwSize);
|
||||||
|
DWORD GetBufferSize() { return m_dwBufferSize; }
|
||||||
|
//void CopyBuffer(const char* pbSrc, DWORD dwSrcSize);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void Initialize();
|
||||||
|
|
||||||
|
BYTE * m_pbBuffer;
|
||||||
|
DWORD m_dwBufferSize;
|
||||||
|
|
||||||
|
THeader * m_pHeader;
|
||||||
|
const BYTE * m_pbIn;
|
||||||
|
bool m_bCompressed;
|
||||||
|
|
||||||
|
bool m_bInBuffer;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static DWORD ms_dwFourCC;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CLZO : public CSingleton<CLZO>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CLZO();
|
||||||
|
virtual ~CLZO();
|
||||||
|
|
||||||
|
bool CompressMemory(CLZObject & rObj, const void * pIn, UINT uiInLen);
|
||||||
|
bool CompressEncryptedMemory(CLZObject & rObj, const void * pIn, UINT uiInLen, DWORD * pdwKey);
|
||||||
|
bool Decompress(CLZObject & rObj, const BYTE * pbBuf, DWORD * pdwKey = NULL);
|
||||||
|
BYTE * GetWorkMemory();
|
||||||
|
|
||||||
|
private:
|
||||||
|
BYTE * m_pWorkMem;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
#ifndef __VK_H__
|
||||||
|
#define __VK_H__
|
||||||
|
#ifndef VK_0
|
||||||
|
#define VK_0 0x30
|
||||||
|
#define VK_1 0x31
|
||||||
|
#define VK_2 0x32
|
||||||
|
#define VK_3 0x33
|
||||||
|
#define VK_4 0x34
|
||||||
|
#define VK_5 0x35
|
||||||
|
#define VK_6 0x36
|
||||||
|
#define VK_7 0x37
|
||||||
|
#define VK_8 0x38
|
||||||
|
#define VK_9 0x39
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef VK_A
|
||||||
|
#define VK_A 0x41
|
||||||
|
#define VK_B 0x42
|
||||||
|
#define VK_C 0x43
|
||||||
|
#define VK_D 0x44
|
||||||
|
#define VK_E 0x45
|
||||||
|
#define VK_F 0x46
|
||||||
|
#define VK_G 0x47
|
||||||
|
#define VK_H 0x48
|
||||||
|
#define VK_I 0x49
|
||||||
|
#define VK_J 0x4A
|
||||||
|
#define VK_K 0x4B
|
||||||
|
#define VK_L 0x4C
|
||||||
|
#define VK_M 0x4D
|
||||||
|
#define VK_N 0x4E
|
||||||
|
#define VK_O 0x4F
|
||||||
|
#define VK_P 0x50
|
||||||
|
#define VK_Q 0x51
|
||||||
|
#define VK_R 0x52
|
||||||
|
#define VK_S 0x53
|
||||||
|
#define VK_T 0x54
|
||||||
|
#define VK_U 0x55
|
||||||
|
#define VK_V 0x56
|
||||||
|
#define VK_W 0x57
|
||||||
|
#define VK_X 0x58
|
||||||
|
#define VK_Y 0x59
|
||||||
|
#define VK_Z 0x5A
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
#ifndef AFX_IMAGE_DXTC_H__4B89D8D0_7857_11D4_9630_00A0C996DE3D__INCLUDED_
|
||||||
|
#define AFX_IMAGE_DXTC_H__4B89D8D0_7857_11D4_9630_00A0C996DE3D__INCLUDED_
|
||||||
|
|
||||||
|
#if _MSC_VER > 1000
|
||||||
|
#pragma once
|
||||||
|
#endif // _MSC_VER > 1000
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
enum EPixFormat
|
||||||
|
{
|
||||||
|
PF_ARGB,
|
||||||
|
PF_DXT1,
|
||||||
|
PF_DXT2,
|
||||||
|
PF_DXT3,
|
||||||
|
PF_DXT4,
|
||||||
|
PF_DXT5,
|
||||||
|
PF_UNKNOWN
|
||||||
|
};
|
||||||
|
|
||||||
|
#define MAX_MIPLEVELS 12
|
||||||
|
|
||||||
|
#ifndef DUMMYUNIONNAMEN
|
||||||
|
#if defined(__cplusplus) || !defined(NONAMELESSUNION)
|
||||||
|
#define DUMMYUNIONNAMEN(n)
|
||||||
|
#else
|
||||||
|
#define DUMMYUNIONNAMEN(n) u##n
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct _XDDPIXELFORMAT
|
||||||
|
{
|
||||||
|
DWORD dwSize; // size of structure
|
||||||
|
DWORD dwFlags; // pixel format flags
|
||||||
|
DWORD dwFourCC; // (FOURCC code)
|
||||||
|
|
||||||
|
union
|
||||||
|
{
|
||||||
|
DWORD dwRGBBitCount; // how many bits per pixel
|
||||||
|
DWORD dwYUVBitCount; // how many bits per pixel
|
||||||
|
DWORD dwZBufferBitDepth; // how many total bits/pixel in z buffer (including any stencil bits)
|
||||||
|
DWORD dwAlphaBitDepth; // how many bits for alpha channels
|
||||||
|
DWORD dwLuminanceBitCount; // how many bits per pixel
|
||||||
|
DWORD dwBumpBitCount; // how many bits per "buxel", total
|
||||||
|
DWORD dwPrivateFormatBitCount;// Bits per pixel of private driver formats. Only valid in texture
|
||||||
|
// format list and if DDPF_D3DFORMAT is set
|
||||||
|
} DUMMYUNIONNAMEN(1);
|
||||||
|
union
|
||||||
|
{
|
||||||
|
DWORD dwRBitMask; // mask for red bit
|
||||||
|
DWORD dwYBitMask; // mask for Y bits
|
||||||
|
DWORD dwStencilBitDepth; // how many stencil bits (note: dwZBufferBitDepth-dwStencilBitDepth is total Z-only bits)
|
||||||
|
DWORD dwLuminanceBitMask; // mask for luminance bits
|
||||||
|
DWORD dwBumpDuBitMask; // mask for bump map U delta bits
|
||||||
|
DWORD dwOperations; // DDPF_D3DFORMAT Operations
|
||||||
|
} DUMMYUNIONNAMEN(2);
|
||||||
|
union
|
||||||
|
{
|
||||||
|
DWORD dwGBitMask; // mask for green bits
|
||||||
|
DWORD dwUBitMask; // mask for U bits
|
||||||
|
DWORD dwZBitMask; // mask for Z bits
|
||||||
|
DWORD dwBumpDvBitMask; // mask for bump map V delta bits
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
WORD wFlipMSTypes; // Multisample methods supported via flip for this D3DFORMAT
|
||||||
|
WORD wBltMSTypes; // Multisample methods supported via blt for this D3DFORMAT
|
||||||
|
} MultiSampleCaps;
|
||||||
|
|
||||||
|
} DUMMYUNIONNAMEN(3);
|
||||||
|
union
|
||||||
|
{
|
||||||
|
DWORD dwBBitMask; // mask for blue bits
|
||||||
|
DWORD dwVBitMask; // mask for V bits
|
||||||
|
DWORD dwStencilBitMask; // mask for stencil bits
|
||||||
|
DWORD dwBumpLuminanceBitMask; // mask for luminance in bump map
|
||||||
|
} DUMMYUNIONNAMEN(4);
|
||||||
|
union
|
||||||
|
{
|
||||||
|
DWORD dwRGBAlphaBitMask; // mask for alpha channel
|
||||||
|
DWORD dwYUVAlphaBitMask; // mask for alpha channel
|
||||||
|
DWORD dwLuminanceAlphaBitMask;// mask for alpha channel
|
||||||
|
DWORD dwRGBZBitMask; // mask for Z channel
|
||||||
|
DWORD dwYUVZBitMask; // mask for Z channel
|
||||||
|
} DUMMYUNIONNAMEN(5);
|
||||||
|
} XDDPIXELFORMAT;
|
||||||
|
|
||||||
|
|
||||||
|
class CDXTCImage
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CDXTCImage();
|
||||||
|
virtual ~CDXTCImage();
|
||||||
|
|
||||||
|
void Initialize();
|
||||||
|
void Clear();
|
||||||
|
|
||||||
|
public:
|
||||||
|
const BYTE * m_pbCompBufferByLevels[MAX_MIPLEVELS];
|
||||||
|
std::vector<BYTE> m_bCompVector[MAX_MIPLEVELS];
|
||||||
|
|
||||||
|
int m_nCompSize;
|
||||||
|
int m_nCompLineSz;
|
||||||
|
|
||||||
|
char m_strFormat[32];
|
||||||
|
EPixFormat m_CompFormat;
|
||||||
|
|
||||||
|
long m_lPitch;
|
||||||
|
DWORD m_dwMipMapCount;
|
||||||
|
bool m_bMipTexture; // texture has mipmaps?
|
||||||
|
DWORD m_dwFlags;
|
||||||
|
|
||||||
|
int m_nWidth; // in pixels of uncompressed image
|
||||||
|
int m_nHeight;
|
||||||
|
|
||||||
|
XDDPIXELFORMAT m_xddPixelFormat;
|
||||||
|
|
||||||
|
bool LoadFromFile(const char * filename); // true if success
|
||||||
|
bool LoadFromMemory(const BYTE * c_pbMap);
|
||||||
|
bool LoadHeaderFromMemory(const BYTE * c_pbMap);
|
||||||
|
bool Copy(int miplevel, BYTE * pbDest, long lDestPitch);
|
||||||
|
|
||||||
|
void Decompress(int miplevel, DWORD * pdwDest);
|
||||||
|
void DecompressDXT1(int miplevel, DWORD * pdwDest);
|
||||||
|
void DecompressDXT3(int miplevel, DWORD * pdwDest);
|
||||||
|
void DecompressDXT5(int miplevel, DWORD * pdwDest);
|
||||||
|
void DecompressARGB(int miplevel, DWORD * pdwDest);
|
||||||
|
|
||||||
|
VOID DecodePixelFormat(CHAR* strPixelFormat, XDDPIXELFORMAT* pddpf);
|
||||||
|
|
||||||
|
void Unextract(BYTE * pbDest, int iWidth, int iHeight, int iPitch);
|
||||||
|
/*
|
||||||
|
struct TimingInfo; // defined in Image_DXTC.cpp
|
||||||
|
void RunTimingSession(); // run a few methods & time the code
|
||||||
|
|
||||||
|
// must use dxt5 texture
|
||||||
|
void Time_Decomp5_01(int ntimes, TimingInfo * info);
|
||||||
|
void Time_Decomp5_02(int ntimes, TimingInfo * info);
|
||||||
|
void Time_Decomp5_03(int ntimes, TimingInfo * info);
|
||||||
|
void Time_Decomp5_04(int ntimes, TimingInfo * info);
|
||||||
|
*/
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // #ifndef AFX_IMAGE_DXTC_H__4B89D8D0_7857_11D4_9630_00A0C996DE3D__INCLUDED_
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
// stdafx.h : include file for standard system include files,
|
||||||
|
// or project specific include files that are used frequently, but
|
||||||
|
// are changed infrequently
|
||||||
|
//
|
||||||
|
|
||||||
|
#if !defined(AFX_STDAFX_H__BCF68E23_E7D8_4BF3_A905_AFDBEF92B0F6__INCLUDED_)
|
||||||
|
#define AFX_STDAFX_H__BCF68E23_E7D8_4BF3_A905_AFDBEF92B0F6__INCLUDED_
|
||||||
|
|
||||||
|
#if _MSC_VER > 1000
|
||||||
|
#pragma once
|
||||||
|
#endif // _MSC_VER > 1000
|
||||||
|
|
||||||
|
#pragma warning(disable:4786)
|
||||||
|
|
||||||
|
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||||
|
|
||||||
|
//#include <crtdbg.h>
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#pragma warning(push, 3)
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#pragma warning(pop)
|
||||||
|
|
||||||
|
inline void _TraceForImage(const char* c_szFormat, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start(args, c_szFormat);
|
||||||
|
|
||||||
|
static char szBuf[1024];
|
||||||
|
_vsnprintf(szBuf, sizeof(szBuf), c_szFormat, args);
|
||||||
|
#ifdef _DEBUG
|
||||||
|
OutputDebugString(szBuf);
|
||||||
|
#endif
|
||||||
|
va_end(args);
|
||||||
|
printf(szBuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma warning(default:4018)
|
||||||
|
|
||||||
|
// TODO: reference additional headers your program requires here
|
||||||
|
|
||||||
|
//{{AFX_INSERT_LOCATION}}
|
||||||
|
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||||
|
|
||||||
|
#endif // !defined(AFX_STDAFX_H__BCF68E23_E7D8_4BF3_A905_AFDBEF92B0F6__INCLUDED_)
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Resource.h"
|
||||||
|
#include "Ref.h"
|
||||||
|
#include "CollisionData.h"
|
||||||
|
|
||||||
|
typedef struct SHeightData
|
||||||
|
{
|
||||||
|
char szName[32+1];
|
||||||
|
std::vector<D3DXVECTOR3> v3VertexVector;
|
||||||
|
} THeightData;
|
||||||
|
|
||||||
|
typedef std::vector<THeightData> THeightDataVector;
|
||||||
|
|
||||||
|
class CAttributeData : public CResource
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef CRef<CAttributeData> TRef;
|
||||||
|
|
||||||
|
/*
|
||||||
|
enum ECollisionType
|
||||||
|
{
|
||||||
|
COLLISION_TYPE_PLANE,
|
||||||
|
COLLISION_TYPE_BOX,
|
||||||
|
COLLISION_TYPE_SPHERE,
|
||||||
|
COLLISION_TYPE_CYLINDER,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct SCollisionData
|
||||||
|
{
|
||||||
|
DWORD dwType;
|
||||||
|
char szName[32+1];
|
||||||
|
|
||||||
|
D3DXVECTOR3 v3Position;
|
||||||
|
float fDimensions[3];
|
||||||
|
D3DXQUATERNION quatRotation;
|
||||||
|
} TCollisionData;*/
|
||||||
|
|
||||||
|
public:
|
||||||
|
static TType Type();
|
||||||
|
|
||||||
|
public:
|
||||||
|
CAttributeData(const char * c_szFileName);
|
||||||
|
virtual ~CAttributeData();
|
||||||
|
|
||||||
|
//DWORD GetCollisionDataCount() const;
|
||||||
|
//BOOL GetCollisionDataPointer(DWORD dwIndex, const TCollisionData ** c_ppCollisionData) const;
|
||||||
|
const CStaticCollisionDataVector & GetCollisionDataVector() const;
|
||||||
|
const THeightDataVector & GetHeightDataVector() const;
|
||||||
|
|
||||||
|
size_t AddCollisionData(const CStaticCollisionData& collisionData); // return m_StaticCollisionDataVector.size();
|
||||||
|
|
||||||
|
DWORD GetHeightDataCount() const;
|
||||||
|
BOOL GetHeightDataPointer(DWORD dwIndex, const THeightData ** c_ppHeightData) const;
|
||||||
|
|
||||||
|
float GetMaximizeRadius();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool OnLoad(int iSize, const void * c_pvBuf);
|
||||||
|
void OnClear();
|
||||||
|
bool OnIsEmpty() const;
|
||||||
|
bool OnIsType(TType type);
|
||||||
|
void OnSelfDestruct();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
float m_fMaximizeRadius;
|
||||||
|
|
||||||
|
//std::vector<TCollisionData> m_CollisionDataVector;
|
||||||
|
CStaticCollisionDataVector m_StaticCollisionDataVector;
|
||||||
|
THeightDataVector m_HeightDataVector;
|
||||||
|
};
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include "AttributeData.h"
|
||||||
|
#include "Pool.h"
|
||||||
|
|
||||||
|
class CAttributeInstance
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CAttributeInstance();
|
||||||
|
virtual ~CAttributeInstance();
|
||||||
|
|
||||||
|
void Clear();
|
||||||
|
BOOL IsEmpty() const;
|
||||||
|
|
||||||
|
const char * GetDataFileName() const;
|
||||||
|
|
||||||
|
// NOTE : Object 전용
|
||||||
|
void SetObjectPointer(CAttributeData * pAttributeData);
|
||||||
|
void RefreshObject(const D3DXMATRIX & c_rmatGlobal);
|
||||||
|
CAttributeData * GetObjectPointer() const;
|
||||||
|
|
||||||
|
bool Picking(const D3DXVECTOR3 & v, const D3DXVECTOR3 & dir, float & out_x, float & out_y);
|
||||||
|
|
||||||
|
BOOL IsInHeight(float fx, float fy);
|
||||||
|
BOOL GetHeight(float fx, float fy, float * pfHeight);
|
||||||
|
|
||||||
|
BOOL IsHeightData() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void SetGlobalMatrix(const D3DXMATRIX & c_rmatGlobal);
|
||||||
|
void SetGlobalPosition(const D3DXVECTOR3 & c_rv3Position);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
float m_fCollisionRadius;
|
||||||
|
float m_fHeightRadius;
|
||||||
|
|
||||||
|
D3DXMATRIX m_matGlobal;
|
||||||
|
|
||||||
|
std::vector< std::vector<D3DXVECTOR3> > m_v3HeightDataVector;
|
||||||
|
|
||||||
|
CAttributeData::TRef m_roAttributeData;
|
||||||
|
|
||||||
|
/*
|
||||||
|
BOOL m_isHeightCached;
|
||||||
|
struct SHeightCacheData
|
||||||
|
{
|
||||||
|
float fxMin;
|
||||||
|
float fyMin;
|
||||||
|
float fxMax;
|
||||||
|
float fyMax;
|
||||||
|
DWORD dwxStep;
|
||||||
|
DWORD dwyStep;
|
||||||
|
std::vector<float> kVec_fHeight;
|
||||||
|
} m_kHeightCacheData;
|
||||||
|
*/
|
||||||
|
|
||||||
|
public:
|
||||||
|
static void CreateSystem(UINT uCapacity);
|
||||||
|
static void DestroySystem();
|
||||||
|
|
||||||
|
static CAttributeInstance* New();
|
||||||
|
static void Delete(CAttributeInstance* pkInst);
|
||||||
|
|
||||||
|
static CDynamicPool<CAttributeInstance> ms_kPool;
|
||||||
|
};
|
||||||
@@ -0,0 +1,285 @@
|
|||||||
|
// Camera.h: interface for the CCamera class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if !defined(AFX_CAMERA_H__C5D086BE_7A03_4246_9145_336747C47D9E__INCLUDED_)
|
||||||
|
#define AFX_CAMERA_H__C5D086BE_7A03_4246_9145_336747C47D9E__INCLUDED_
|
||||||
|
|
||||||
|
#if _MSC_VER > 1000
|
||||||
|
#pragma once
|
||||||
|
#endif // _MSC_VER > 1000
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
#include "../EterBase/Singleton.h"
|
||||||
|
#include "Ray.h"
|
||||||
|
|
||||||
|
const float CAMERA_TARGET_STANDARD = 100.0f;
|
||||||
|
const float CAMERA_TARGET_FACE = 150.0f;
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum _eCameraState_
|
||||||
|
{
|
||||||
|
CAMERA_STATE_NORMAL,
|
||||||
|
CAMERA_STATE_CANTGODOWN,
|
||||||
|
CAMERA_STATE_CANTGORIGHT,
|
||||||
|
CAMERA_STATE_CANTGOLEFT,
|
||||||
|
CAMERA_STATE_SCREEN_BY_BUILDING,
|
||||||
|
CAMERA_STATE_SCREEN_BY_BUILDING_AND_TOOCLOSE,
|
||||||
|
} eCameraState;
|
||||||
|
|
||||||
|
class CCamera
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CCamera();
|
||||||
|
virtual ~CCamera();
|
||||||
|
|
||||||
|
static void SetCameraMaxDistance(float fMax);
|
||||||
|
|
||||||
|
void Lock();
|
||||||
|
void Unlock();
|
||||||
|
bool IsLock();
|
||||||
|
|
||||||
|
void Wheel(int nWheelLen);
|
||||||
|
bool Drag(int nMouseX, int nMouseY, LPPOINT lpReturnPoint);
|
||||||
|
|
||||||
|
bool EndDrag();
|
||||||
|
void BeginDrag(int nMouseX, int nMouseY);
|
||||||
|
|
||||||
|
bool IsDraging();
|
||||||
|
|
||||||
|
void SetResistance(float fResistance);
|
||||||
|
|
||||||
|
private:
|
||||||
|
const CCamera & operator = (const CCamera &) ; // 지원하지 않음
|
||||||
|
CCamera (const CCamera & ) ; //지원하지 않음
|
||||||
|
|
||||||
|
// Camera Update
|
||||||
|
eCameraState m_eCameraState;
|
||||||
|
eCameraState m_eCameraStatePrev;
|
||||||
|
float m_fPitchBackup;
|
||||||
|
float m_fRollBackup;
|
||||||
|
float m_fDistanceBackup;
|
||||||
|
float m_fTargetZBackUp;
|
||||||
|
|
||||||
|
D3DXVECTOR3 m_v3EyeBackup;
|
||||||
|
|
||||||
|
unsigned long m_ulNumScreenBuilding;
|
||||||
|
|
||||||
|
// protected:
|
||||||
|
|
||||||
|
bool m_isLock;
|
||||||
|
|
||||||
|
// Attributes for view matrix
|
||||||
|
D3DXVECTOR3 m_v3Eye;
|
||||||
|
D3DXVECTOR3 m_v3Target;
|
||||||
|
D3DXVECTOR3 m_v3Up;
|
||||||
|
|
||||||
|
// m_v3View = m_v3Target - m_v3Eye
|
||||||
|
D3DXVECTOR3 m_v3View;
|
||||||
|
// m_v3Cross = Cross(m_v3Up, m_v3View)
|
||||||
|
D3DXVECTOR3 m_v3Cross;
|
||||||
|
|
||||||
|
//ViewMatrixes
|
||||||
|
D3DXMATRIX m_matView;
|
||||||
|
D3DXMATRIX m_matInverseView;
|
||||||
|
D3DXMATRIX m_matBillboard; // Special matrix for billboarding effects
|
||||||
|
|
||||||
|
//추가분
|
||||||
|
float m_fPitch;
|
||||||
|
float m_fRoll;
|
||||||
|
float m_fDistance;
|
||||||
|
|
||||||
|
// 카메라 AI를 위한 Ray 들
|
||||||
|
|
||||||
|
// 카메라를 둘러싼 Ray
|
||||||
|
CRay m_kCameraBottomToTerrainRay;
|
||||||
|
CRay m_kCameraFrontToTerrainRay;
|
||||||
|
CRay m_kCameraBackToTerrainRay;
|
||||||
|
CRay m_kCameraLeftToTerrainRay;
|
||||||
|
CRay m_kCameraRightToTerrainRay;
|
||||||
|
|
||||||
|
CRay m_kTargetToCameraBottomRay;
|
||||||
|
|
||||||
|
CRay m_ViewRay;
|
||||||
|
CRay m_kLeftObjectCollisionRay;
|
||||||
|
CRay m_kTopObjectCollisionRay;
|
||||||
|
CRay m_kRightObjectCollisionRay;
|
||||||
|
CRay m_kBottomObjectCollisionRay;
|
||||||
|
|
||||||
|
float m_fTerrainCollisionRadius;
|
||||||
|
float m_fObjectCollisionRadius;
|
||||||
|
|
||||||
|
// protected:
|
||||||
|
float m_fTarget_;
|
||||||
|
|
||||||
|
float m_fEyeGroundHeightRatio;
|
||||||
|
float m_fTargetHeightLimitRatio;
|
||||||
|
float m_fPitchSum;
|
||||||
|
float m_fRollSum;
|
||||||
|
|
||||||
|
long m_lMousePosX;
|
||||||
|
long m_lMousePosY;
|
||||||
|
|
||||||
|
bool m_bDrag;
|
||||||
|
|
||||||
|
// protected:
|
||||||
|
// 물리
|
||||||
|
D3DXVECTOR3 m_v3AngularAcceleration;
|
||||||
|
D3DXVECTOR3 m_v3AngularVelocity;
|
||||||
|
|
||||||
|
float m_fResistance;
|
||||||
|
public:
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
// 물리
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
void SetAngularAcceleration(D3DXVECTOR3 v3AngularAcceleration) { m_v3AngularAcceleration = v3AngularAcceleration; }
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
// AI
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
void SetTerrainCollisionRadius(float fTerrainCollisionRadius) { m_fTerrainCollisionRadius = fTerrainCollisionRadius; }
|
||||||
|
void SetObjectCollisionRadius(float fObjectCollisionRadius) { m_fObjectCollisionRadius = fObjectCollisionRadius; }
|
||||||
|
|
||||||
|
CRay & GetViewRay() { return m_ViewRay; }
|
||||||
|
CRay & GetLeftObjectCollisionRay() { return m_kLeftObjectCollisionRay; }
|
||||||
|
CRay & GetRightObjectCollisionRay() { return m_kRightObjectCollisionRay; }
|
||||||
|
CRay & GetTopObjectCollisionRay() { return m_kTopObjectCollisionRay; }
|
||||||
|
CRay & GetBottomObjectCollisionRay() { return m_kBottomObjectCollisionRay; }
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
// Update
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
void Update();
|
||||||
|
eCameraState GetCameraState() {return m_eCameraState;}
|
||||||
|
void SetCameraState(eCameraState eNewCameraState);
|
||||||
|
void IncreaseNumSrcreenBuilding();
|
||||||
|
void ResetNumScreenBuilding();
|
||||||
|
unsigned long & GetNumScreenBuilding() { return m_ulNumScreenBuilding; }
|
||||||
|
|
||||||
|
const float & GetPitchBackUp() { return m_fPitchBackup; }
|
||||||
|
const float & GetRollBackUp() { return m_fRollBackup; }
|
||||||
|
const float & GetDistanceBackUp() { return m_fDistanceBackup; }
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
// properties
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
const D3DXVECTOR3 & GetEye() const { return m_v3Eye; }
|
||||||
|
const D3DXVECTOR3 & GetTarget() const { return m_v3Target; }
|
||||||
|
const D3DXVECTOR3 & GetUp() const { return m_v3Up; }
|
||||||
|
const D3DXVECTOR3 & GetView() const { return m_v3View; }
|
||||||
|
const D3DXVECTOR3 & GetCross() const { return m_v3Cross; }
|
||||||
|
|
||||||
|
const D3DXMATRIX & GetViewMatrix() const { return m_matView; }
|
||||||
|
const D3DXMATRIX & GetInverseViewMatrix() const { return m_matInverseView; }
|
||||||
|
const D3DXMATRIX & GetBillboardMatrix()const { return m_matBillboard; }
|
||||||
|
|
||||||
|
void SetViewParams(const D3DXVECTOR3 & v3Eye, const D3DXVECTOR3& v3Target, const D3DXVECTOR3& v3Up );
|
||||||
|
|
||||||
|
void SetEye(const D3DXVECTOR3 & v3Eye);
|
||||||
|
void SetTarget(const D3DXVECTOR3 & v3Target);
|
||||||
|
void SetUp(const D3DXVECTOR3 & v3Up);
|
||||||
|
|
||||||
|
float GetPitch() const { return m_fPitch; }
|
||||||
|
float GetRoll() const { return m_fRoll; }
|
||||||
|
float GetDistance() const { return m_fDistance; }
|
||||||
|
|
||||||
|
void Pitch(const float fPitchDelta); //돌아가는 각도를 넣는다.
|
||||||
|
void Roll(const float fRollDelta);
|
||||||
|
void SetDistance(const float fdistance);
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
// camera movement
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// 말그대로 이동... 카메라 위치와 타겟 위치가 모두 달라진다.
|
||||||
|
void Move(const D3DXVECTOR3 & v3Displacement);
|
||||||
|
// 줌.. 카메라 위치만 이동.. 타겟 위치는 고정...
|
||||||
|
void Zoom(float fRatio);
|
||||||
|
|
||||||
|
// 뷰 방향으로 이동.. 타겟위치가 달라지므로 줌과는 다르다...
|
||||||
|
void MoveAlongView(float fDistance);
|
||||||
|
// 카메라 옆 방향으로 이동..
|
||||||
|
void MoveAlongCross(float fDistance);
|
||||||
|
// 카메라 업벡터 방향으로 이동...
|
||||||
|
void MoveAlongUp(float fDistance);
|
||||||
|
|
||||||
|
// 카메라 옆 방향으로 이동... MoveAlongCross과 동일..
|
||||||
|
void MoveLateral(float fDistance);
|
||||||
|
// 뷰 방향의 Z 성분을 무시한 XY평면 방향으로 이동..
|
||||||
|
void MoveFront(float fDistance);
|
||||||
|
// Z방향(연직 방향)으로 이동...
|
||||||
|
void MoveVertical(float fDistance);
|
||||||
|
|
||||||
|
// //카메라 위치는 고정시키고 머리만 든다. 타겟이 달라지겠죠?
|
||||||
|
// //회전각을 라디안이 아닌 "도(Degree)"로 넣는다.
|
||||||
|
// void RotateUpper(float fDegree);
|
||||||
|
|
||||||
|
// 타겟 중심으로 돈다. Eterlib의 SetAroundCamera의 기능과 유사...
|
||||||
|
// fPitchDegree는 수평(0도)로부터 아랫쪽으로 꺽어지는 각도...
|
||||||
|
// fRollDegree는 타겟 중심으로 시계방향으로 도는 각도...
|
||||||
|
void RotateEyeAroundTarget(float fPitchDegree, float fRollDegree);
|
||||||
|
|
||||||
|
// 도는 중심점을 따로 지정 그 점을 중심으로 돈다. 타겟 점도 달라지겠죠?
|
||||||
|
void RotateEyeAroundPoint(const D3DXVECTOR3 & v3Point, float fPitchDegree, float fRollDegree);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void SetViewMatrix();
|
||||||
|
void CalculateRoll();
|
||||||
|
|
||||||
|
public:
|
||||||
|
float GetTargetHeight();
|
||||||
|
void SetTargetHeight(float fTarget);
|
||||||
|
bool isTerrainCollisionEnable() { return m_bProcessTerrainCollision; }
|
||||||
|
void SetTerrainCollision(bool bEnable) { m_bProcessTerrainCollision = bEnable; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
void ProcessTerrainCollision();
|
||||||
|
void ProcessBuildingCollision();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_bProcessTerrainCollision;
|
||||||
|
|
||||||
|
static float CAMERA_MIN_DISTANCE;
|
||||||
|
static float CAMERA_MAX_DISTANCE;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::map<BYTE, CCamera *> TCameraMap;
|
||||||
|
|
||||||
|
class CCameraManager : public CSingleton<CCameraManager>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum ECameraNum
|
||||||
|
{
|
||||||
|
NO_CURRENT_CAMERA,
|
||||||
|
DEFAULT_PERSPECTIVE_CAMERA,
|
||||||
|
DEFAULT_ORTHO_CAMERA,
|
||||||
|
CAMERA_MAX = 255
|
||||||
|
};
|
||||||
|
|
||||||
|
CCameraManager();
|
||||||
|
virtual ~CCameraManager();
|
||||||
|
|
||||||
|
bool AddCamera(unsigned char ucCameraNum);
|
||||||
|
bool RemoveCamera(unsigned char ucCameraNum);
|
||||||
|
|
||||||
|
CCamera * GetCurrentCamera();
|
||||||
|
void SetCurrentCamera(unsigned char ucCameraNum);
|
||||||
|
void ResetToPreviousCamera();
|
||||||
|
|
||||||
|
bool isCurrentCamera(unsigned char ucCameraNum);
|
||||||
|
|
||||||
|
unsigned char GetCurrentCameraNum();
|
||||||
|
|
||||||
|
bool isTerrainCollisionEnable();
|
||||||
|
void SetTerrainCollision(bool bEnable);
|
||||||
|
|
||||||
|
private:
|
||||||
|
TCameraMap m_CameraMap;
|
||||||
|
CCamera * m_pCurrentCamera;
|
||||||
|
CCamera * m_pPreviousCamera;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // !defined(AFX_CAMERA_H__C5D086BE_7A03_4246_9145_336747C47D9E__INCLUDED_)
|
||||||
@@ -0,0 +1,206 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// Collision Detection
|
||||||
|
typedef struct SSphereData
|
||||||
|
{
|
||||||
|
D3DXVECTOR3 v3Position;
|
||||||
|
float fRadius;
|
||||||
|
} TSphereData;
|
||||||
|
|
||||||
|
typedef struct SPlaneData
|
||||||
|
{
|
||||||
|
D3DXVECTOR3 v3Position;
|
||||||
|
D3DXVECTOR3 v3Normal;
|
||||||
|
|
||||||
|
D3DXVECTOR3 v3QuadPosition[4];
|
||||||
|
D3DXVECTOR3 v3InsideVector[4];
|
||||||
|
} TPlaneData;
|
||||||
|
|
||||||
|
typedef struct SAABBData
|
||||||
|
{
|
||||||
|
D3DXVECTOR3 v3Min;
|
||||||
|
D3DXVECTOR3 v3Max;
|
||||||
|
|
||||||
|
} TAABBData;
|
||||||
|
|
||||||
|
typedef struct SOBBData
|
||||||
|
{
|
||||||
|
D3DXVECTOR3 v3Min;
|
||||||
|
D3DXVECTOR3 v3Max;
|
||||||
|
D3DXMATRIX matRot;
|
||||||
|
|
||||||
|
} TOBBData;
|
||||||
|
|
||||||
|
typedef struct SCylinderData
|
||||||
|
{
|
||||||
|
D3DXVECTOR3 v3Position;
|
||||||
|
float fRadius;
|
||||||
|
float fHeight;
|
||||||
|
} TCylinderData;
|
||||||
|
|
||||||
|
enum ECollisionType
|
||||||
|
{
|
||||||
|
COLLISION_TYPE_PLANE,
|
||||||
|
COLLISION_TYPE_BOX,
|
||||||
|
COLLISION_TYPE_SPHERE,
|
||||||
|
COLLISION_TYPE_CYLINDER,
|
||||||
|
COLLISION_TYPE_AABB,
|
||||||
|
COLLISION_TYPE_OBB,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CDynamicSphereInstance
|
||||||
|
{
|
||||||
|
D3DXVECTOR3 v3Position;
|
||||||
|
D3DXVECTOR3 v3LastPosition;
|
||||||
|
|
||||||
|
float fRadius;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CStaticCollisionData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DWORD dwType;
|
||||||
|
char szName[32+1];
|
||||||
|
|
||||||
|
D3DXVECTOR3 v3Position;
|
||||||
|
float fDimensions[3];
|
||||||
|
D3DXQUATERNION quatRotation;
|
||||||
|
};
|
||||||
|
|
||||||
|
void DestroyCollisionInstanceSystem();
|
||||||
|
|
||||||
|
typedef std::vector<CStaticCollisionData> CStaticCollisionDataVector;
|
||||||
|
|
||||||
|
/////////////////////////////////////////////
|
||||||
|
// Base
|
||||||
|
class CBaseCollisionInstance
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void Render(D3DFILLMODE d3dFillMode = D3DFILL_SOLID) = 0;
|
||||||
|
|
||||||
|
bool MovementCollisionDynamicSphere(const CDynamicSphereInstance & s) const
|
||||||
|
{
|
||||||
|
return OnMovementCollisionDynamicSphere(s);
|
||||||
|
}
|
||||||
|
bool CollisionDynamicSphere(const CDynamicSphereInstance & s) const
|
||||||
|
{
|
||||||
|
return OnCollisionDynamicSphere(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
D3DXVECTOR3 GetCollisionMovementAdjust(const CDynamicSphereInstance & s) const
|
||||||
|
{
|
||||||
|
return OnGetCollisionMovementAdjust(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Destroy();
|
||||||
|
|
||||||
|
static CBaseCollisionInstance * BuildCollisionInstance(const CStaticCollisionData * c_pCollisionData, const D3DXMATRIX * pMat);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual D3DXVECTOR3 OnGetCollisionMovementAdjust(const CDynamicSphereInstance & s) const = 0;
|
||||||
|
virtual bool OnMovementCollisionDynamicSphere(const CDynamicSphereInstance & s) const = 0;
|
||||||
|
virtual bool OnCollisionDynamicSphere(const CDynamicSphereInstance & s) const = 0;
|
||||||
|
virtual void OnDestroy() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
/////////////////////////////////////////////
|
||||||
|
// Sphere
|
||||||
|
class CSphereCollisionInstance : public CBaseCollisionInstance
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TSphereData & GetAttribute();
|
||||||
|
const TSphereData & GetAttribute() const;
|
||||||
|
virtual void Render(D3DFILLMODE d3dFillMode = D3DFILL_SOLID);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void OnDestroy();
|
||||||
|
bool OnMovementCollisionDynamicSphere(const CDynamicSphereInstance & s) const;
|
||||||
|
virtual bool OnCollisionDynamicSphere(const CDynamicSphereInstance & s) const;
|
||||||
|
virtual D3DXVECTOR3 OnGetCollisionMovementAdjust(const CDynamicSphereInstance & s) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
TSphereData m_attribute;
|
||||||
|
};
|
||||||
|
|
||||||
|
/////////////////////////////////////////////
|
||||||
|
// Plane
|
||||||
|
class CPlaneCollisionInstance : public CBaseCollisionInstance
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TPlaneData & GetAttribute();
|
||||||
|
const TPlaneData & GetAttribute() const;
|
||||||
|
virtual void Render(D3DFILLMODE d3dFillMode = D3DFILL_SOLID);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void OnDestroy();
|
||||||
|
bool OnMovementCollisionDynamicSphere(const CDynamicSphereInstance & s) const;
|
||||||
|
virtual bool OnCollisionDynamicSphere(const CDynamicSphereInstance & s) const;
|
||||||
|
virtual D3DXVECTOR3 OnGetCollisionMovementAdjust(const CDynamicSphereInstance & s) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
TPlaneData m_attribute;
|
||||||
|
};
|
||||||
|
|
||||||
|
/////////////////////////////////////////////
|
||||||
|
// AABB (Aligned Axis Bounding Box)
|
||||||
|
class CAABBCollisionInstance : public CBaseCollisionInstance
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TAABBData & GetAttribute();
|
||||||
|
const TAABBData & GetAttribute() const;
|
||||||
|
virtual void Render(D3DFILLMODE d3dFillMode = D3DFILL_SOLID);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void OnDestroy();
|
||||||
|
bool OnMovementCollisionDynamicSphere(const CDynamicSphereInstance & s) const;
|
||||||
|
virtual bool OnCollisionDynamicSphere(const CDynamicSphereInstance & s) const;
|
||||||
|
virtual D3DXVECTOR3 OnGetCollisionMovementAdjust(const CDynamicSphereInstance & s) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
TAABBData m_attribute;
|
||||||
|
};
|
||||||
|
|
||||||
|
/////////////////////////////////////////////
|
||||||
|
// OBB
|
||||||
|
class COBBCollisionInstance : public CBaseCollisionInstance
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TOBBData & GetAttribute();
|
||||||
|
const TOBBData & GetAttribute() const;
|
||||||
|
virtual void Render(D3DFILLMODE d3dFillMode = D3DFILL_SOLID);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void OnDestroy();
|
||||||
|
bool OnMovementCollisionDynamicSphere(const CDynamicSphereInstance & s) const;
|
||||||
|
virtual bool OnCollisionDynamicSphere(const CDynamicSphereInstance & s) const;
|
||||||
|
virtual D3DXVECTOR3 OnGetCollisionMovementAdjust(const CDynamicSphereInstance & s) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
TOBBData m_attribute;
|
||||||
|
};
|
||||||
|
|
||||||
|
/////////////////////////////////////////////
|
||||||
|
// Cylinder
|
||||||
|
class CCylinderCollisionInstance : public CBaseCollisionInstance
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TCylinderData & GetAttribute();
|
||||||
|
const TCylinderData & GetAttribute() const;
|
||||||
|
virtual void Render(D3DFILLMODE d3dFillMode = D3DFILL_SOLID);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void OnDestroy();
|
||||||
|
bool OnMovementCollisionDynamicSphere(const CDynamicSphereInstance & s) const;
|
||||||
|
virtual bool OnCollisionDynamicSphere(const CDynamicSphereInstance & s) const;
|
||||||
|
virtual D3DXVECTOR3 OnGetCollisionMovementAdjust(const CDynamicSphereInstance & s) const;
|
||||||
|
|
||||||
|
bool CollideCylinderVSDynamicSphere(const TCylinderData & c_rattribute, const CDynamicSphereInstance & s) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
TCylinderData m_attribute;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::vector<CSphereCollisionInstance> CSphereCollisionInstanceVector;
|
||||||
|
typedef std::vector<CDynamicSphereInstance> CDynamicSphereInstanceVector;
|
||||||
|
typedef std::vector<CBaseCollisionInstance*> CCollisionInstanceVector;
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
class CColorTransitionHelper
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CColorTransitionHelper();
|
||||||
|
~CColorTransitionHelper();
|
||||||
|
|
||||||
|
void Clear(const float & c_rfRed,
|
||||||
|
const float & c_rfGreen,
|
||||||
|
const float & c_rfBlue,
|
||||||
|
const float & c_rfAlpha);
|
||||||
|
void SetSrcColor(const float & c_rfRed,
|
||||||
|
const float & c_rfGreen,
|
||||||
|
const float & c_rfBlue,
|
||||||
|
const float & c_rfAlpha);
|
||||||
|
void SetTransition(const float & c_rfRed,
|
||||||
|
const float & c_rfGreen,
|
||||||
|
const float & c_rfBlue,
|
||||||
|
const float & c_rfAlpha,
|
||||||
|
const DWORD & dwDuration);
|
||||||
|
const D3DCOLOR & GetCurColor();// { return m_dwCurColor; }
|
||||||
|
|
||||||
|
void StartTransition();
|
||||||
|
bool Update();
|
||||||
|
|
||||||
|
bool isTransitionStarted() { return m_bTransitionStarted; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
D3DCOLOR m_dwCurColor; // 현재 색
|
||||||
|
|
||||||
|
DWORD m_dwStartTime; // 바뀌기 시작하는 시간
|
||||||
|
DWORD m_dwDuration; // 얼마 동안에 바뀌는가?
|
||||||
|
|
||||||
|
bool m_bTransitionStarted;
|
||||||
|
|
||||||
|
float m_fSrcRed, m_fSrcGreen, m_fSrcBlue, m_fSrcAlpha;
|
||||||
|
float m_fDstRed, m_fDstGreen, m_fDstBlue, m_fDstAlpha;
|
||||||
|
};
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
class CFuncObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CFuncObject()
|
||||||
|
{
|
||||||
|
Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~CFuncObject()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Clear()
|
||||||
|
{
|
||||||
|
m_pSelfObject = NULL;
|
||||||
|
m_pFuncObject = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Set(T* pSelfObject, void (T::*pFuncObject)())
|
||||||
|
{
|
||||||
|
m_pSelfObject = pSelfObject;
|
||||||
|
m_pFuncObject = pFuncObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsEmpty()
|
||||||
|
{
|
||||||
|
if (m_pSelfObject != NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (m_pFuncObject != NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Run()
|
||||||
|
{
|
||||||
|
if (m_pSelfObject)
|
||||||
|
if (m_pFuncObject)
|
||||||
|
(m_pSelfObject->*m_pFuncObject)();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
T * m_pSelfObject;
|
||||||
|
void (T::*m_pFuncObject) ();
|
||||||
|
};
|
||||||
@@ -0,0 +1,312 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "GrpDetector.h"
|
||||||
|
#include "Ray.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
void PixelPositionToD3DXVECTOR3(const D3DXVECTOR3& c_rkPPosSrc, D3DXVECTOR3* pv3Dst);
|
||||||
|
void D3DXVECTOR3ToPixelPosition(const D3DXVECTOR3& c_rv3Src, D3DXVECTOR3* pv3Dst);
|
||||||
|
|
||||||
|
class CGraphicTexture;
|
||||||
|
|
||||||
|
typedef WORD TIndex;
|
||||||
|
|
||||||
|
typedef struct SFace
|
||||||
|
{
|
||||||
|
TIndex indices[3];
|
||||||
|
} TFace;
|
||||||
|
|
||||||
|
typedef D3DXVECTOR3 TPosition;
|
||||||
|
|
||||||
|
typedef D3DXVECTOR3 TNormal;
|
||||||
|
|
||||||
|
typedef D3DXVECTOR2 TTextureCoordinate;
|
||||||
|
|
||||||
|
typedef DWORD TDiffuse;
|
||||||
|
typedef DWORD TAmbient;
|
||||||
|
typedef DWORD TSpecular;
|
||||||
|
|
||||||
|
typedef union UDepth
|
||||||
|
{
|
||||||
|
float f;
|
||||||
|
long l;
|
||||||
|
DWORD dw;
|
||||||
|
} TDepth;
|
||||||
|
|
||||||
|
typedef struct SVertex
|
||||||
|
{
|
||||||
|
float x, y, z;
|
||||||
|
DWORD color;
|
||||||
|
float u, v;
|
||||||
|
} TVertex;
|
||||||
|
|
||||||
|
struct STVertex
|
||||||
|
{
|
||||||
|
float x, y, z, rhw;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SPVertex
|
||||||
|
{
|
||||||
|
float x, y, z;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct SPDVertex
|
||||||
|
{
|
||||||
|
float x, y, z;
|
||||||
|
DWORD color;
|
||||||
|
} TPDVertex;
|
||||||
|
|
||||||
|
struct SPDTVertexRaw
|
||||||
|
{
|
||||||
|
float px, py, pz;
|
||||||
|
DWORD diffuse;
|
||||||
|
float u, v;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct SPTVertex
|
||||||
|
{
|
||||||
|
TPosition position;
|
||||||
|
TTextureCoordinate texCoord;
|
||||||
|
} TPTVertex;
|
||||||
|
|
||||||
|
typedef struct SPDTVertex
|
||||||
|
{
|
||||||
|
TPosition position;
|
||||||
|
TDiffuse diffuse;
|
||||||
|
TTextureCoordinate texCoord;
|
||||||
|
} TPDTVertex;
|
||||||
|
|
||||||
|
typedef struct SPNTVertex
|
||||||
|
{
|
||||||
|
TPosition position;
|
||||||
|
TNormal normal;
|
||||||
|
TTextureCoordinate texCoord;
|
||||||
|
} TPNTVertex;
|
||||||
|
|
||||||
|
typedef struct SPNT2Vertex
|
||||||
|
{
|
||||||
|
TPosition position;
|
||||||
|
TNormal normal;
|
||||||
|
TTextureCoordinate texCoord;
|
||||||
|
TTextureCoordinate texCoord2;
|
||||||
|
} TPNT2Vertex;
|
||||||
|
|
||||||
|
typedef struct SPDT2Vertex
|
||||||
|
{
|
||||||
|
TPosition position;
|
||||||
|
DWORD diffuse;
|
||||||
|
TTextureCoordinate texCoord;
|
||||||
|
TTextureCoordinate texCoord2;
|
||||||
|
} TPDT2Vertex;
|
||||||
|
|
||||||
|
typedef struct SNameInfo
|
||||||
|
{
|
||||||
|
DWORD name;
|
||||||
|
TDepth depth;
|
||||||
|
} TNameInfo;
|
||||||
|
|
||||||
|
typedef struct SBoundBox
|
||||||
|
{
|
||||||
|
float sx, sy, sz;
|
||||||
|
float ex, ey, ez;
|
||||||
|
int meshIndex;
|
||||||
|
int boneIndex;
|
||||||
|
} TBoundBox;
|
||||||
|
|
||||||
|
const WORD c_FillRectIndices[6] = { 0, 2, 1, 2, 3, 1 };
|
||||||
|
|
||||||
|
/*
|
||||||
|
enum EIndexCount
|
||||||
|
{
|
||||||
|
LINE_INDEX_COUNT = 2,
|
||||||
|
TRIANGLE_INDEX_COUNT = 2*3,
|
||||||
|
RECTANGLE_INDEX_COUNT = 2*4,
|
||||||
|
CUBE_INDEX_COUNT = 2*4*3,
|
||||||
|
FILLED_TRIANGLE_INDEX_COUNT = 3,
|
||||||
|
FILLED_RECTANGLE_INDEX_COUNT = 3*2,
|
||||||
|
FILLED_CUBE_INDEX_COUNT = 3*2*6,
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
|
class CGraphicBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static DWORD GetAvailableTextureMemory();
|
||||||
|
static const D3DXMATRIX& GetViewMatrix();
|
||||||
|
static const D3DXMATRIX & GetIdentityMatrix();
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
DEFAULT_IB_LINE,
|
||||||
|
DEFAULT_IB_LINE_TRI,
|
||||||
|
DEFAULT_IB_LINE_RECT,
|
||||||
|
DEFAULT_IB_LINE_CUBE,
|
||||||
|
DEFAULT_IB_FILL_TRI,
|
||||||
|
DEFAULT_IB_FILL_RECT,
|
||||||
|
DEFAULT_IB_FILL_CUBE,
|
||||||
|
DEFAULT_IB_NUM,
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
CGraphicBase();
|
||||||
|
virtual ~CGraphicBase();
|
||||||
|
|
||||||
|
void SetSimpleCamera(float x, float y, float z, float pitch, float roll);
|
||||||
|
void SetEyeCamera(float xEye, float yEye, float zEye, float xCenter, float yCenter, float zCenter, float xUp, float yUp, float zUp);
|
||||||
|
void SetAroundCamera(float distance, float pitch, float roll, float lookAtZ = 0.0f);
|
||||||
|
void SetPositionCamera(float fx, float fy, float fz, float fDistance, float fPitch, float fRotation);
|
||||||
|
void MoveCamera(float fdeltax, float fdeltay, float fdeltaz);
|
||||||
|
|
||||||
|
void GetTargetPosition(float * px, float * py, float * pz);
|
||||||
|
void GetCameraPosition(float * px, float * py, float * pz);
|
||||||
|
void SetOrtho2D(float hres, float vres, float zres);
|
||||||
|
void SetOrtho3D(float hres, float vres, float zmin, float zmax);
|
||||||
|
void SetPerspective(float fov, float aspect, float nearz, float farz);
|
||||||
|
float GetFOV();
|
||||||
|
void GetClipPlane(float * fNearY, float * fFarY)
|
||||||
|
{
|
||||||
|
*fNearY = ms_fNearY;
|
||||||
|
*fFarY = ms_fFarY;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
void PushMatrix();
|
||||||
|
|
||||||
|
void MultMatrix( const D3DXMATRIX* pMat );
|
||||||
|
void MultMatrixLocal( const D3DXMATRIX* pMat );
|
||||||
|
|
||||||
|
void Translate(float x, float y, float z);
|
||||||
|
void Rotate(float degree, float x, float y, float z);
|
||||||
|
void RotateLocal(float degree, float x, float y, float z);
|
||||||
|
void RotateYawPitchRollLocal(float fYaw, float fPitch, float fRoll);
|
||||||
|
void Scale(float x, float y, float z);
|
||||||
|
void PopMatrix();
|
||||||
|
void LoadMatrix(const D3DXMATRIX & c_rSrcMatrix);
|
||||||
|
void GetMatrix(D3DXMATRIX * pRetMatrix) const;
|
||||||
|
const D3DXMATRIX * GetMatrixPointer() const;
|
||||||
|
|
||||||
|
// Special Routine
|
||||||
|
void GetSphereMatrix(D3DXMATRIX * pMatrix, float fValue = 0.1f);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
void InitScreenEffect();
|
||||||
|
void SetScreenEffectWaving(float fDuringTime, int iPower);
|
||||||
|
void SetScreenEffectFlashing(float fDuringTime, const D3DXCOLOR & c_rColor);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
DWORD GetColor(float r, float g, float b, float a = 1.0f);
|
||||||
|
|
||||||
|
DWORD GetFaceCount();
|
||||||
|
void ResetFaceCount();
|
||||||
|
HRESULT GetLastResult();
|
||||||
|
|
||||||
|
void UpdateProjMatrix();
|
||||||
|
void UpdateViewMatrix();
|
||||||
|
|
||||||
|
void SetViewport(DWORD dwX, DWORD dwY, DWORD dwWidth, DWORD dwHeight, float fMinZ, float fMaxZ);
|
||||||
|
static void GetBackBufferSize(UINT* puWidth, UINT* puHeight);
|
||||||
|
static bool IsTLVertexClipping();
|
||||||
|
static bool IsFastTNL();
|
||||||
|
static bool IsLowTextureMemory();
|
||||||
|
static bool IsHighTextureMemory();
|
||||||
|
|
||||||
|
static void SetDefaultIndexBuffer(UINT eDefIB);
|
||||||
|
static bool SetPDTStream(SPDTVertexRaw* pVertices, UINT uVtxCount);
|
||||||
|
static bool SetPDTStream(SPDTVertex* pVertices, UINT uVtxCount);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static D3DXMATRIX ms_matIdentity;
|
||||||
|
|
||||||
|
static D3DXMATRIX ms_matView;
|
||||||
|
static D3DXMATRIX ms_matProj;
|
||||||
|
static D3DXMATRIX ms_matInverseView;
|
||||||
|
static D3DXMATRIX ms_matInverseViewYAxis;
|
||||||
|
|
||||||
|
static D3DXMATRIX ms_matWorld;
|
||||||
|
static D3DXMATRIX ms_matWorldView;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
//void UpdatePrePipeLineMatrix();
|
||||||
|
void UpdatePipeLineMatrix();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// 각종 D3DX Mesh 들 (컬루젼 데이터 등을 표시활 때 쓴다)
|
||||||
|
static LPD3DXMESH ms_lpSphereMesh;
|
||||||
|
static LPD3DXMESH ms_lpCylinderMesh;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static HRESULT ms_hLastResult;
|
||||||
|
|
||||||
|
static int ms_iWidth;
|
||||||
|
static int ms_iHeight;
|
||||||
|
|
||||||
|
static UINT ms_iD3DAdapterInfo;
|
||||||
|
static UINT ms_iD3DDevInfo;
|
||||||
|
static UINT ms_iD3DModeInfo;
|
||||||
|
static D3D_CDisplayModeAutoDetector ms_kD3DDetector;
|
||||||
|
|
||||||
|
static HWND ms_hWnd;
|
||||||
|
static HDC ms_hDC;
|
||||||
|
static LPDIRECT3D8 ms_lpd3d;
|
||||||
|
static LPDIRECT3DDEVICE8 ms_lpd3dDevice;
|
||||||
|
static ID3DXMatrixStack* ms_lpd3dMatStack;
|
||||||
|
static D3DVIEWPORT8 ms_Viewport;
|
||||||
|
|
||||||
|
static DWORD ms_faceCount;
|
||||||
|
static D3DCAPS8 ms_d3dCaps;
|
||||||
|
static D3DPRESENT_PARAMETERS ms_d3dPresentParameter;
|
||||||
|
|
||||||
|
static DWORD ms_dwD3DBehavior;
|
||||||
|
static DWORD ms_ptVS;
|
||||||
|
static DWORD ms_pntVS;
|
||||||
|
static DWORD ms_pnt2VS;
|
||||||
|
|
||||||
|
static D3DXMATRIX ms_matScreen0;
|
||||||
|
static D3DXMATRIX ms_matScreen1;
|
||||||
|
static D3DXMATRIX ms_matScreen2;
|
||||||
|
//static D3DXMATRIX ms_matPrePipeLine;
|
||||||
|
|
||||||
|
static D3DXVECTOR3 ms_vtPickRayOrig;
|
||||||
|
static D3DXVECTOR3 ms_vtPickRayDir;
|
||||||
|
|
||||||
|
static float ms_fFieldOfView;
|
||||||
|
static float ms_fAspect;
|
||||||
|
static float ms_fNearY;
|
||||||
|
static float ms_fFarY;
|
||||||
|
|
||||||
|
// 2004.11.18.myevan.DynamicVertexBuffer로 교체
|
||||||
|
/*
|
||||||
|
static std::vector<TIndex> ms_lineIdxVector;
|
||||||
|
static std::vector<TIndex> ms_lineTriIdxVector;
|
||||||
|
static std::vector<TIndex> ms_lineRectIdxVector;
|
||||||
|
static std::vector<TIndex> ms_lineCubeIdxVector;
|
||||||
|
|
||||||
|
static std::vector<TIndex> ms_fillTriIdxVector;
|
||||||
|
static std::vector<TIndex> ms_fillRectIdxVector;
|
||||||
|
static std::vector<TIndex> ms_fillCubeIdxVector;
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Screen Effect - Waving, Flashing and so on..
|
||||||
|
static DWORD ms_dwWavingEndTime;
|
||||||
|
static int ms_iWavingPower;
|
||||||
|
static DWORD ms_dwFlashingEndTime;
|
||||||
|
static D3DXCOLOR ms_FlashingColor;
|
||||||
|
|
||||||
|
// Terrain picking용 Ray... CCamera 이용하는 버전.. 기존의 Ray와 통합 필요...
|
||||||
|
static CRay ms_Ray;
|
||||||
|
|
||||||
|
//
|
||||||
|
static bool ms_bSupportDXT;
|
||||||
|
static bool ms_isLowTextureMemory;
|
||||||
|
static bool ms_isHighTextureMemory;
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PDT_VERTEX_NUM = 16,
|
||||||
|
PDT_VERTEXBUFFER_NUM = 100,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static LPDIRECT3DVERTEXBUFFER8 ms_alpd3dPDTVB[PDT_VERTEXBUFFER_NUM];
|
||||||
|
static LPDIRECT3DINDEXBUFFER8 ms_alpd3dDefIB[DEFAULT_IB_NUM];
|
||||||
|
};
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "GrpBase.h"
|
||||||
|
|
||||||
|
class CGraphicCollisionObject : public CGraphicBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CGraphicCollisionObject();
|
||||||
|
virtual ~CGraphicCollisionObject();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool IntersectTriangle(const D3DXVECTOR3& c_orig, const D3DXVECTOR3& c_dir, const D3DXVECTOR3& c_v0, const D3DXVECTOR3& c_v1, const D3DXVECTOR3& c_v2, float* pu, float* pv, float* pt);
|
||||||
|
bool IntersectBoundBox(const D3DXMATRIX* c_pmatWorld, const TBoundBox& c_rboundBox, float* pu, float* pv, float* pt);
|
||||||
|
bool IntersectCube(const D3DXMATRIX* c_pmatWorld, float sx, float sy, float sz, float ex, float ey, float ez, D3DXVECTOR3 & RayOriginal, D3DXVECTOR3 & RayDirection, float* pu, float* pv, float* pt);
|
||||||
|
bool IntersectIndexedMesh(const D3DXMATRIX* c_pmatWorld, const void* vertices, int step, int vtxCount, const void* indices, int idxCount, D3DXVECTOR3 & RayOriginal, D3DXVECTOR3 & RayDirection, float* pu, float* pv, float* pt);
|
||||||
|
bool IntersectMesh(const D3DXMATRIX * c_pmatWorld, const void * vertices, DWORD dwStep, DWORD dwvtxCount, D3DXVECTOR3 & RayOriginal, D3DXVECTOR3 & RayDirection, float* pu, float* pv, float* pt);
|
||||||
|
|
||||||
|
bool IntersectSphere(const D3DXVECTOR3 & c_rv3Position, float fRadius, const D3DXVECTOR3 & c_rv3RayOriginal, const D3DXVECTOR3 & c_rv3RayDirection);
|
||||||
|
bool IntersectCylinder(const D3DXVECTOR3 & c_rv3Position, float fRadius, float fHeight, const D3DXVECTOR3 & c_rv3RayOriginal, const D3DXVECTOR3 & c_rv3RayDirection);
|
||||||
|
|
||||||
|
// NOTE : ms_vtPickRayOrig와 ms_vtPickRayDir를 CGraphicBGase가 가지고 있는데
|
||||||
|
// 굳이 인자로 넣어줘야 하는 이유가 있는가? Customize를 위해서? - [levites]
|
||||||
|
bool IntersectSphere(const D3DXVECTOR3 & c_rv3Position, float fRadius);
|
||||||
|
bool IntersectCylinder(const D3DXVECTOR3 & c_rv3Position, float fRadius, float fHeight);
|
||||||
|
};
|
||||||
@@ -0,0 +1,166 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <d3d8.h>
|
||||||
|
#include <string>
|
||||||
|
typedef BOOL (*PFNCONFIRMDEVICE) (D3DCAPS8& rkD3DCaps, UINT uBehavior, D3DFORMAT eD3DFmt);
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
D3DDEVICETYPE_HAL,
|
||||||
|
D3DDEVICETYPE_REF,
|
||||||
|
D3DDEVICETYPE_NUM,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct D3D_SModeInfo
|
||||||
|
{
|
||||||
|
UINT m_uScrWidth;
|
||||||
|
UINT m_uScrHeight;
|
||||||
|
UINT m_uScrDepthBit;
|
||||||
|
UINT m_dwD3DBehavior;
|
||||||
|
D3DFORMAT m_eD3DFmtPixel;
|
||||||
|
D3DFORMAT m_eD3DFmtDepthStencil;
|
||||||
|
|
||||||
|
VOID GetString(std::string* pstEnumList);
|
||||||
|
};
|
||||||
|
|
||||||
|
class D3D_CAdapterDisplayModeList
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
D3D_CAdapterDisplayModeList() {}
|
||||||
|
~D3D_CAdapterDisplayModeList() {}
|
||||||
|
VOID Build(IDirect3D8& rkD3D, D3DFORMAT eD3DFmtDefault, UINT iAdapter);
|
||||||
|
|
||||||
|
UINT GetDisplayModeNum();
|
||||||
|
UINT GetPixelFormatNum();
|
||||||
|
|
||||||
|
const D3DDISPLAYMODE& GetDisplayModer(UINT iD3DDM);
|
||||||
|
const D3DFORMAT& GetPixelFormatr(UINT iD3DFmt);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
D3DDISPLAYMODE_MAX = 100,
|
||||||
|
D3DFORMAT_MAX = 20,
|
||||||
|
|
||||||
|
FILTEROUT_LOWRESOLUTION_WIDTH = 640,
|
||||||
|
FILTEROUT_LOWRESOLUTION_HEIGHT = 480,
|
||||||
|
};
|
||||||
|
|
||||||
|
protected:
|
||||||
|
D3DDISPLAYMODE m_akD3DDM[D3DDISPLAYMODE_MAX];
|
||||||
|
D3DFORMAT m_aeD3DFmt[D3DFORMAT_MAX];
|
||||||
|
|
||||||
|
UINT m_uD3DDMNum;
|
||||||
|
UINT m_uD3DFmtNum;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class D3D_CDeviceInfo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
D3D_CDeviceInfo() {}
|
||||||
|
~D3D_CDeviceInfo() {}
|
||||||
|
BOOL Build(IDirect3D8& rkD3D, UINT iAdapter, UINT iDevType, D3D_CAdapterDisplayModeList& rkD3DADMList, PFNCONFIRMDEVICE pfnConfirmDevice);
|
||||||
|
BOOL Find(UINT uScrWidth, UINT uScrHeight, UINT uScrDepthBits, BOOL isWindowed, UINT* piD3DModeInfo);
|
||||||
|
|
||||||
|
UINT GetD3DModeInfoNum();
|
||||||
|
|
||||||
|
VOID GetString(std::string* pstEnumList);
|
||||||
|
|
||||||
|
BOOL FindDepthStencilFormat(IDirect3D8& rkD3D, UINT iAdapter, D3DDEVTYPE DeviceType, D3DFORMAT TargetFormat, D3DFORMAT* pDepthStencilFormat);
|
||||||
|
|
||||||
|
D3D_SModeInfo& GetD3DModeInfor(UINT iD3DModeInfo);
|
||||||
|
D3D_SModeInfo* GetD3DModeInfop(UINT iD3DModeInfo);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
D3DMODEINFO_NUM = 150,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
const TCHAR* m_szDevDesc;
|
||||||
|
|
||||||
|
D3DDEVTYPE m_eD3DDevType;
|
||||||
|
D3DCAPS8 m_kD3DCaps;
|
||||||
|
BOOL m_canDoWindowed;
|
||||||
|
|
||||||
|
UINT m_iCurD3DModeInfo;
|
||||||
|
UINT m_uD3DModeInfoNum;
|
||||||
|
D3D_SModeInfo m_akD3DModeInfo[D3DMODEINFO_NUM];
|
||||||
|
|
||||||
|
|
||||||
|
BOOL m_isWindowed;
|
||||||
|
|
||||||
|
D3DMULTISAMPLE_TYPE m_eD3DMSTWindowed;
|
||||||
|
D3DMULTISAMPLE_TYPE m_eD3DMSTFullscreen;
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static const CHAR* msc_aszD3DDevDesc[D3DDEVICETYPE_NUM];
|
||||||
|
static const D3DDEVTYPE msc_aeD3DDevType[D3DDEVICETYPE_NUM];
|
||||||
|
};
|
||||||
|
|
||||||
|
class D3D_CAdapterInfo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
D3D_CAdapterInfo() {}
|
||||||
|
~D3D_CAdapterInfo() {}
|
||||||
|
BOOL Find(UINT uScrWidth, UINT uScrHeight, UINT uScrDepthBits, BOOL isWindowed, UINT* piD3DModeInfo, UINT* piD3DDevInfo);
|
||||||
|
|
||||||
|
BOOL Build(IDirect3D8& rkD3D, UINT iAdapter, PFNCONFIRMDEVICE pfnConfirmDevice);
|
||||||
|
VOID GetString(std::string* pstEnumList);
|
||||||
|
|
||||||
|
D3DADAPTER_IDENTIFIER8& GetIdentifier()
|
||||||
|
{
|
||||||
|
return m_kD3DAdapterIdentifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
D3DDISPLAYMODE& GetDesktopD3DDisplayModer();
|
||||||
|
D3DDISPLAYMODE* GetDesktopD3DDisplayModep();
|
||||||
|
|
||||||
|
D3D_CDeviceInfo* GetD3DDeviceInfop(UINT iD3DDevInfo);
|
||||||
|
D3D_SModeInfo* GetD3DModeInfop(UINT iD3DDevInfo, UINT iD3DModeInfo);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
D3DDEVICEINFO_NUM = 5,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
D3DADAPTER_IDENTIFIER8 m_kD3DAdapterIdentifier;
|
||||||
|
D3DDISPLAYMODE m_kD3DDMDesktop;
|
||||||
|
|
||||||
|
UINT m_iCurD3DDevInfo;
|
||||||
|
UINT m_uD3DDevInfoNum;
|
||||||
|
D3D_CDeviceInfo m_akD3DDevInfo[D3DDEVICEINFO_NUM];
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class D3D_CDisplayModeAutoDetector
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
D3D_CDisplayModeAutoDetector();
|
||||||
|
~D3D_CDisplayModeAutoDetector();
|
||||||
|
|
||||||
|
BOOL Find(UINT uScrWidth, UINT uScrHeight, UINT uScrDepthBits, BOOL isWindowed, UINT* piD3DModeInfo, UINT* piD3DDevInfo, UINT* piD3DAdapterInfo);
|
||||||
|
BOOL Build(IDirect3D8& rkD3D, PFNCONFIRMDEVICE pfnConfirmDevice);
|
||||||
|
|
||||||
|
D3D_CAdapterInfo* GetD3DAdapterInfop(UINT iD3DAdapterInfo);
|
||||||
|
D3D_SModeInfo* GetD3DModeInfop(UINT iD3DAdapterInfo, UINT iD3DDevInfo, UINT iD3DModeInfo);
|
||||||
|
|
||||||
|
VOID GetString(std::string* pstEnumList);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
D3DADAPTERINFO_NUM = 10,
|
||||||
|
};
|
||||||
|
|
||||||
|
protected:
|
||||||
|
D3D_CAdapterInfo m_akD3DAdapterInfo[D3DADAPTERINFO_NUM];
|
||||||
|
UINT m_uD3DAdapterInfoCount;
|
||||||
|
};
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
#ifndef __INC_GRPIMAGE_H__
|
||||||
|
#define __INC_GRPIMAGE_H__
|
||||||
|
|
||||||
|
#include "Ref.h"
|
||||||
|
#include "Resource.h"
|
||||||
|
#include "GrpImageTexture.h"
|
||||||
|
|
||||||
|
class CGraphicImage : public CResource
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef CRef<CGraphicImage> TRef;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static TType Type();
|
||||||
|
|
||||||
|
public:
|
||||||
|
CGraphicImage(const char* c_szFileName, DWORD dwFilter = D3DX_FILTER_LINEAR);
|
||||||
|
virtual ~CGraphicImage();
|
||||||
|
|
||||||
|
virtual bool CreateDeviceObjects();
|
||||||
|
virtual void DestroyDeviceObjects();
|
||||||
|
|
||||||
|
int GetWidth() const;
|
||||||
|
int GetHeight() const;
|
||||||
|
|
||||||
|
const RECT & GetRectReference() const;
|
||||||
|
|
||||||
|
const CGraphicTexture & GetTextureReference() const;
|
||||||
|
CGraphicTexture * GetTexturePointer();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool OnLoad(int iSize, const void * c_pvBuf);
|
||||||
|
|
||||||
|
void OnClear();
|
||||||
|
bool OnIsEmpty() const;
|
||||||
|
bool OnIsType(TType type);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
CGraphicImageTexture m_imageTexture;
|
||||||
|
RECT m_rect;
|
||||||
|
DWORD m_dwFilter;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "GrpImage.h"
|
||||||
|
#include "GrpIndexBuffer.h"
|
||||||
|
#include "GrpVertexBufferDynamic.h"
|
||||||
|
#include "Pool.h"
|
||||||
|
|
||||||
|
class CGraphicImageInstance
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static DWORD Type();
|
||||||
|
BOOL IsType(DWORD dwType);
|
||||||
|
|
||||||
|
public:
|
||||||
|
CGraphicImageInstance();
|
||||||
|
virtual ~CGraphicImageInstance();
|
||||||
|
|
||||||
|
void Destroy();
|
||||||
|
|
||||||
|
void Render();
|
||||||
|
|
||||||
|
void SetDiffuseColor(float fr, float fg, float fb, float fa);
|
||||||
|
void SetPosition(float fx, float fy);
|
||||||
|
|
||||||
|
void SetImagePointer(CGraphicImage* pImage);
|
||||||
|
void ReloadImagePointer(CGraphicImage* pImage);
|
||||||
|
bool IsEmpty() const;
|
||||||
|
|
||||||
|
int GetWidth();
|
||||||
|
int GetHeight();
|
||||||
|
|
||||||
|
CGraphicTexture * GetTexturePointer();
|
||||||
|
const CGraphicTexture & GetTextureReference() const;
|
||||||
|
CGraphicImage * GetGraphicImagePointer();
|
||||||
|
|
||||||
|
bool operator == (const CGraphicImageInstance & rhs) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void Initialize();
|
||||||
|
|
||||||
|
virtual void OnRender();
|
||||||
|
virtual void OnSetImagePointer();
|
||||||
|
|
||||||
|
virtual BOOL OnIsType(DWORD dwType);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
D3DXCOLOR m_DiffuseColor;
|
||||||
|
D3DXVECTOR2 m_v2Position;
|
||||||
|
|
||||||
|
CGraphicImage::TRef m_roImage;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static void CreateSystem(UINT uCapacity);
|
||||||
|
static void DestroySystem();
|
||||||
|
|
||||||
|
static CGraphicImageInstance* New();
|
||||||
|
static void Delete(CGraphicImageInstance* pkImgInst);
|
||||||
|
|
||||||
|
static CDynamicPool<CGraphicImageInstance> ms_kPool;
|
||||||
|
};
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "GrpTexture.h"
|
||||||
|
#include "../EterImageLib/DXTCImage.h"
|
||||||
|
|
||||||
|
class CGraphicImageTexture : public CGraphicTexture
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CGraphicImageTexture();
|
||||||
|
virtual ~CGraphicImageTexture();
|
||||||
|
|
||||||
|
void Destroy();
|
||||||
|
|
||||||
|
bool Create(UINT width, UINT height, D3DFORMAT d3dFmt, DWORD dwFilter = D3DX_FILTER_LINEAR);
|
||||||
|
bool CreateDeviceObjects();
|
||||||
|
|
||||||
|
void CreateFromTexturePointer(const CGraphicTexture* c_pSrcTexture);
|
||||||
|
bool CreateFromDiskFile(const char* c_szFileName, D3DFORMAT d3dFmt, DWORD dwFilter = D3DX_FILTER_LINEAR);
|
||||||
|
bool CreateFromMemoryFile(UINT bufSize, const void* c_pvBuf, D3DFORMAT d3dFmt, DWORD dwFilter = D3DX_FILTER_LINEAR);
|
||||||
|
bool CreateDDSTexture(CDXTCImage & image, const BYTE * c_pbBuf);
|
||||||
|
|
||||||
|
void SetFileName(const char * c_szFileName);
|
||||||
|
|
||||||
|
bool Lock(int* pRetPitch, void** ppRetPixels, int level=0);
|
||||||
|
void Unlock(int level=0);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void Initialize();
|
||||||
|
|
||||||
|
D3DFORMAT m_d3dFmt;
|
||||||
|
DWORD m_dwFilter;
|
||||||
|
|
||||||
|
std::string m_stFileName;
|
||||||
|
};
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "GrpBase.h"
|
||||||
|
|
||||||
|
class CGraphicIndexBuffer : public CGraphicBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CGraphicIndexBuffer();
|
||||||
|
virtual ~CGraphicIndexBuffer();
|
||||||
|
|
||||||
|
void Destroy();
|
||||||
|
bool Create(int idxCount, D3DFORMAT d3dFmt);
|
||||||
|
bool Create(int faceCount, TFace* faces);
|
||||||
|
|
||||||
|
bool CreateDeviceObjects();
|
||||||
|
void DestroyDeviceObjects();
|
||||||
|
|
||||||
|
bool Copy(int bufSize, const void* srcIndices);
|
||||||
|
|
||||||
|
bool Lock(void** pretIndices) const;
|
||||||
|
void Unlock() const;
|
||||||
|
|
||||||
|
bool Lock(void** pretIndices);
|
||||||
|
void Unlock();
|
||||||
|
|
||||||
|
void SetIndices(int startIndex=0) const;
|
||||||
|
|
||||||
|
LPDIRECT3DINDEXBUFFER8 GetD3DIndexBuffer() const;
|
||||||
|
|
||||||
|
int GetIndexCount() const {return m_iidxCount;}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void Initialize();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
LPDIRECT3DINDEXBUFFER8 m_lpd3dIdxBuf;
|
||||||
|
DWORD m_dwBufferSize;
|
||||||
|
D3DFORMAT m_d3dFmt;
|
||||||
|
int m_iidxCount;
|
||||||
|
};
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "GrpCollisionObject.h"
|
||||||
|
#include "../SphereLib/frustum.h"
|
||||||
|
|
||||||
|
|
||||||
|
class CScreen : public CGraphicCollisionObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CScreen();
|
||||||
|
virtual ~CScreen();
|
||||||
|
|
||||||
|
void ClearDepthBuffer();
|
||||||
|
void Clear();
|
||||||
|
bool Begin();
|
||||||
|
void End();
|
||||||
|
void Show(HWND hWnd = NULL);
|
||||||
|
void Show(RECT * pSrcRect);
|
||||||
|
void Show(RECT * pSrcRect, HWND hWnd);
|
||||||
|
|
||||||
|
void RenderLine2d(float sx, float sy, float ex, float ey, float z=0.0f);
|
||||||
|
void RenderBox2d(float sx, float sy, float ex, float ey, float z=0.0f);
|
||||||
|
void RenderBar2d(float sx, float sy, float ex, float ey, float z=0.0f);
|
||||||
|
void RenderGradationBar2d(float sx, float sy, float ex, float ey, DWORD dwStartColor, DWORD dwEndColor, float ez=0.0f);
|
||||||
|
void RenderCircle2d(float fx, float fy, float fz, float fRadius, int iStep = 50);
|
||||||
|
void RenderCircle3d(float fx, float fy, float fz, float fRadius, int iStep = 50);
|
||||||
|
|
||||||
|
void RenderLine3d(float sx, float sy, float sz, float ex, float ey, float ez);
|
||||||
|
void RenderBox3d(float sx, float sy, float sz, float ex, float ey, float ez);
|
||||||
|
void RenderBar3d(float sx, float sy, float sz, float ex, float ey, float ez);
|
||||||
|
void RenderBar3d(const D3DXVECTOR3 * c_pv3Positions);
|
||||||
|
void RenderGradationBar3d(float sx, float sy, float sz, float ex, float ey, float ez, DWORD dwStartColor, DWORD dwEndColor);
|
||||||
|
|
||||||
|
void RenderLineCube(float sx, float sy, float sz, float ex, float ey, float ez);
|
||||||
|
void RenderCube(float sx, float sy, float sz, float ex, float ey, float ez);
|
||||||
|
void RenderCube(float sx, float sy, float sz, float ex, float ey, float ez, D3DXMATRIX matRotation);
|
||||||
|
void RenderTextureBox(float sx, float sy, float ex, float ey, float z=0.0f, float su=0.0f, float sv=0.0f, float eu=1.0f, float ev=1.0f);
|
||||||
|
void RenderBillboard(D3DXVECTOR3 * Position, D3DXCOLOR & Color);
|
||||||
|
|
||||||
|
void DrawMinorGrid(float xMin, float yMin, float xMax, float yMax, float xminorStep, float yminorStep, float zPos=0);
|
||||||
|
void DrawGrid(float xMin, float yMin, float xMax, float yMax, float xmajorStep, float ymajorStep, float xminorStep, float yminorStep, float zPos=0);
|
||||||
|
|
||||||
|
void RenderD3DXMesh(LPD3DXMESH lpMesh, const D3DXMATRIX * c_pmatWorld, float fx, float fy, float fz, float fRadius, D3DFILLMODE d3dFillMode);
|
||||||
|
void RenderSphere(const D3DXMATRIX * c_pmatWorld, float fx, float fy, float fz, float fRadius, D3DFILLMODE d3dFillMode = D3DFILL_SOLID);
|
||||||
|
void RenderCylinder(const D3DXMATRIX * c_pmatWorld, float fx, float fy, float fz, float fRadius, float fLength, D3DFILLMODE d3dFillMode = D3DFILL_SOLID);
|
||||||
|
|
||||||
|
void SetColorOperation();
|
||||||
|
void SetDiffuseOperation();
|
||||||
|
void SetBlendOperation();
|
||||||
|
void SetOneColorOperation(D3DXCOLOR & rColor);
|
||||||
|
void SetAddColorOperation(D3DXCOLOR & rColor);
|
||||||
|
void SetDiffuseColor(DWORD diffuseColor);
|
||||||
|
void SetDiffuseColor(float r, float g, float b, float a=1.0f);
|
||||||
|
void SetClearColor(float r, float g, float b, float a=1.0f);
|
||||||
|
void SetClearDepth(float depth);
|
||||||
|
void SetClearStencil(DWORD stencil);
|
||||||
|
|
||||||
|
void SetCursorPosition(int x, int y, int hres, int vres); // creates picking ray
|
||||||
|
bool GetCursorPosition(float* px, float* py, float* pz);
|
||||||
|
bool GetCursorXYPosition(float* px, float* py);
|
||||||
|
bool GetCursorZPosition(float* pz);
|
||||||
|
void GetPickingPosition(float t, float* x, float* y, float* z);
|
||||||
|
void ProjectPosition(float x, float y, float z, float * pfX, float * pfY);
|
||||||
|
void ProjectPosition(float x, float y, float z, float * pfX, float * pfY, float * pfZ);
|
||||||
|
void UnprojectPosition(float x, float y, float z, float * pfX, float * pfY, float * pfZ);
|
||||||
|
|
||||||
|
BOOL IsLostDevice();
|
||||||
|
BOOL RestoreDevice();
|
||||||
|
|
||||||
|
void BuildViewFrustum();
|
||||||
|
|
||||||
|
static void Identity();
|
||||||
|
static Frustum & GetFrustum() { return ms_frustum; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static DWORD ms_diffuseColor;
|
||||||
|
static DWORD ms_clearColor;
|
||||||
|
static DWORD ms_clearStencil;
|
||||||
|
static float ms_clearDepth;
|
||||||
|
|
||||||
|
static Frustum ms_frustum;
|
||||||
|
};
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "GrpBase.h"
|
||||||
|
|
||||||
|
class CGraphicTexture : public CGraphicBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual bool IsEmpty() const;
|
||||||
|
|
||||||
|
int GetWidth() const;
|
||||||
|
int GetHeight() const;
|
||||||
|
|
||||||
|
void SetTextureStage(int stage) const;
|
||||||
|
LPDIRECT3DTEXTURE8 GetD3DTexture() const;
|
||||||
|
|
||||||
|
void DestroyDeviceObjects();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
CGraphicTexture();
|
||||||
|
virtual ~CGraphicTexture();
|
||||||
|
|
||||||
|
void Destroy();
|
||||||
|
void Initialize();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool m_bEmpty;
|
||||||
|
|
||||||
|
int m_width;
|
||||||
|
int m_height;
|
||||||
|
|
||||||
|
LPDIRECT3DTEXTURE8 m_lpd3dTexture;
|
||||||
|
};
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "GrpBase.h"
|
||||||
|
|
||||||
|
class CGraphicVertexBuffer : public CGraphicBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CGraphicVertexBuffer();
|
||||||
|
virtual ~CGraphicVertexBuffer();
|
||||||
|
|
||||||
|
void Destroy();
|
||||||
|
virtual bool Create(int vtxCount, DWORD fvf, DWORD usage, D3DPOOL d3dPool);
|
||||||
|
|
||||||
|
bool CreateDeviceObjects();
|
||||||
|
void DestroyDeviceObjects();
|
||||||
|
|
||||||
|
bool Copy(int bufSize, const void* srcVertices);
|
||||||
|
|
||||||
|
bool LockRange(unsigned count, void** pretVertices) const;
|
||||||
|
bool Lock(void** pretVertices) const;
|
||||||
|
bool Unlock() const;
|
||||||
|
|
||||||
|
bool LockDynamic(void** pretVertices);
|
||||||
|
virtual bool Lock(void** pretVertices);
|
||||||
|
bool Unlock();
|
||||||
|
|
||||||
|
void SetStream(int stride, int layer=0) const;
|
||||||
|
|
||||||
|
int GetVertexCount() const;
|
||||||
|
int GetVertexStride() const;
|
||||||
|
DWORD GetFlexibleVertexFormat() const;
|
||||||
|
|
||||||
|
inline LPDIRECT3DVERTEXBUFFER8 GetD3DVertexBuffer() const { return m_lpd3dVB; }
|
||||||
|
inline DWORD GetBufferSize() const { return m_dwBufferSize; }
|
||||||
|
|
||||||
|
bool IsEmpty() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void Initialize();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
LPDIRECT3DVERTEXBUFFER8 m_lpd3dVB;
|
||||||
|
|
||||||
|
DWORD m_dwBufferSize;
|
||||||
|
DWORD m_dwFVF;
|
||||||
|
DWORD m_dwUsage;
|
||||||
|
D3DPOOL m_d3dPool;
|
||||||
|
int m_vtxCount;
|
||||||
|
DWORD m_dwLockFlag;
|
||||||
|
};
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "GrpVertexBuffer.h"
|
||||||
|
|
||||||
|
class CDynamicVertexBuffer : public CGraphicVertexBuffer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CDynamicVertexBuffer();
|
||||||
|
virtual ~CDynamicVertexBuffer();
|
||||||
|
|
||||||
|
bool Create(int vtxCount, int fvf);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int m_vtxCount;
|
||||||
|
int m_fvf;
|
||||||
|
};
|
||||||
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#ifndef __INC_ETERLIB_MUTEX_H__
|
||||||
|
#define __INC_ETERLIB_MUTEX_H__
|
||||||
|
|
||||||
|
class Mutex
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Mutex();
|
||||||
|
~Mutex();
|
||||||
|
|
||||||
|
void Lock();
|
||||||
|
void Unlock();
|
||||||
|
bool Trylock();
|
||||||
|
|
||||||
|
private:
|
||||||
|
CRITICAL_SECTION lock;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef VC_EXTRALEAN
|
||||||
|
|
||||||
|
class CNetworkAddress
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static bool GetHostName(char* szName, int size);
|
||||||
|
|
||||||
|
public:
|
||||||
|
CNetworkAddress();
|
||||||
|
~CNetworkAddress();
|
||||||
|
|
||||||
|
void Clear();
|
||||||
|
|
||||||
|
bool Set(const char* c_szAddr, int port);
|
||||||
|
|
||||||
|
void SetLocalIP();
|
||||||
|
void SetIP(DWORD ip);
|
||||||
|
void SetIP(const char* c_szIP);
|
||||||
|
bool SetDNS(const char* c_szDNS);
|
||||||
|
|
||||||
|
void SetPort(int port);
|
||||||
|
|
||||||
|
int GetPort();
|
||||||
|
int GetSize();
|
||||||
|
|
||||||
|
void GetIP(char* szIP, int len);
|
||||||
|
|
||||||
|
DWORD GetIP();
|
||||||
|
|
||||||
|
operator const SOCKADDR_IN&() const;
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool IsIP(const char* c_szAddr);
|
||||||
|
|
||||||
|
private:
|
||||||
|
SOCKADDR_IN m_sockAddrIn;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
class CNetworkDevice
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CNetworkDevice();
|
||||||
|
virtual ~CNetworkDevice();
|
||||||
|
|
||||||
|
void Destroy();
|
||||||
|
bool Create();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void Initialize();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool m_isWSA;
|
||||||
|
};
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
class CNetworkPacketHeaderMap
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef struct SPacketType
|
||||||
|
{
|
||||||
|
SPacketType(int iSize = 0, bool bFlag = false)
|
||||||
|
{
|
||||||
|
iPacketSize = iSize;
|
||||||
|
isDynamicSizePacket = bFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
int iPacketSize;
|
||||||
|
bool isDynamicSizePacket;
|
||||||
|
} TPacketType;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CNetworkPacketHeaderMap();
|
||||||
|
virtual ~CNetworkPacketHeaderMap();
|
||||||
|
|
||||||
|
void Set(int header, TPacketType rPacketType);
|
||||||
|
bool Get(int header, TPacketType * pPacketType);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::map<int, TPacketType> m_headerMap;
|
||||||
|
};
|
||||||
@@ -0,0 +1,684 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../EterBase/Debug.h"
|
||||||
|
|
||||||
|
//#define DYNAMIC_POOL_STRICT
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
class CDynamicPool
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CDynamicPool()
|
||||||
|
{
|
||||||
|
//Tracen(typeid(T).name());
|
||||||
|
m_uInitCapacity=0;
|
||||||
|
m_uUsedCapacity=0;
|
||||||
|
}
|
||||||
|
virtual ~CDynamicPool()
|
||||||
|
{
|
||||||
|
assert(m_kVct_pkData.empty());
|
||||||
|
//#ifdef _DEBUG
|
||||||
|
// char szText[256];
|
||||||
|
// sprintf(szText, "--------------------------------------------------------------------- %s Pool Capacity %d\n", typeid(T).name(), m_uUsedCapacity);
|
||||||
|
// OutputDebugString(szText);
|
||||||
|
// printf(szText);
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetName(const char* c_szName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Clear()
|
||||||
|
{
|
||||||
|
Destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Destroy()
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
#ifdef _DEBUG
|
||||||
|
if (!m_kVct_pkData.empty())
|
||||||
|
{
|
||||||
|
char szText[256];
|
||||||
|
sprintf(szText, "--------------------------------------------------------------------- %s Pool Destroy\n", typeid(T).name());
|
||||||
|
OutputDebugString(szText);
|
||||||
|
printf(szText);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
*/
|
||||||
|
for (auto v : m_kVct_pkData)
|
||||||
|
Delete(v);
|
||||||
|
m_kVct_pkData.clear();
|
||||||
|
m_kVct_pkFree.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Create(UINT uCapacity)
|
||||||
|
{
|
||||||
|
m_uInitCapacity=uCapacity;
|
||||||
|
m_kVct_pkData.reserve(uCapacity);
|
||||||
|
m_kVct_pkFree.reserve(uCapacity);
|
||||||
|
}
|
||||||
|
T* Alloc()
|
||||||
|
{
|
||||||
|
if (m_kVct_pkFree.empty())
|
||||||
|
{
|
||||||
|
T* pkNewData=new T;
|
||||||
|
m_kVct_pkData.push_back(pkNewData);
|
||||||
|
++m_uUsedCapacity;
|
||||||
|
return pkNewData;
|
||||||
|
}
|
||||||
|
|
||||||
|
T* pkFreeData=m_kVct_pkFree.back();
|
||||||
|
m_kVct_pkFree.pop_back();
|
||||||
|
return pkFreeData;
|
||||||
|
}
|
||||||
|
void Free(T* pkData)
|
||||||
|
{
|
||||||
|
#ifdef DYNAMIC_POOL_STRICT
|
||||||
|
assert(__IsValidData(pkData));
|
||||||
|
assert(!__IsFreeData(pkData));
|
||||||
|
#endif
|
||||||
|
m_kVct_pkFree.push_back(pkData);
|
||||||
|
}
|
||||||
|
void FreeAll()
|
||||||
|
{
|
||||||
|
m_kVct_pkFree=m_kVct_pkData;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD GetCapacity()
|
||||||
|
{
|
||||||
|
return m_kVct_pkData.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool __IsValidData(T* pkData)
|
||||||
|
{
|
||||||
|
if (m_kVct_pkData.end()==std::find(m_kVct_pkData.begin(), m_kVct_pkData.end(), pkData))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool __IsFreeData(T* pkData)
|
||||||
|
{
|
||||||
|
if (m_kVct_pkFree.end()==std::find(m_kVct_pkFree.begin(), m_kVct_pkFree.end(), pkData))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Delete(T* pkData)
|
||||||
|
{
|
||||||
|
delete pkData;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::vector<T*> m_kVct_pkData;
|
||||||
|
std::vector<T*> m_kVct_pkFree;
|
||||||
|
|
||||||
|
UINT m_uInitCapacity;
|
||||||
|
UINT m_uUsedCapacity;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
class CDynamicPoolEx
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CDynamicPoolEx()
|
||||||
|
{
|
||||||
|
m_uInitCapacity=0;
|
||||||
|
m_uUsedCapacity=0;
|
||||||
|
}
|
||||||
|
virtual ~CDynamicPoolEx()
|
||||||
|
{
|
||||||
|
assert(m_kVct_pkFree.size()==m_kVct_pkData.size());
|
||||||
|
Destroy();
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
char szText[256];
|
||||||
|
sprintf(szText, "--------------------------------------------------------------------- %s Pool Capacity %d\n", typeid(T).name(), m_uUsedCapacity);
|
||||||
|
OutputDebugString(szText);
|
||||||
|
printf(szText);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void Clear()
|
||||||
|
{
|
||||||
|
Destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Destroy()
|
||||||
|
{
|
||||||
|
#ifdef _DEBUG
|
||||||
|
if (!m_kVct_pkData.empty())
|
||||||
|
{
|
||||||
|
char szText[256];
|
||||||
|
sprintf(szText, "--------------------------------------------------------------------- %s Pool Destroy\n", typeid(T).name());
|
||||||
|
OutputDebugString(szText);
|
||||||
|
printf(szText);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
for (auto v : m_kVct_pkData)
|
||||||
|
Delete(v);
|
||||||
|
m_kVct_pkData.clear();
|
||||||
|
m_kVct_pkFree.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Create(UINT uCapacity)
|
||||||
|
{
|
||||||
|
m_uInitCapacity=uCapacity;
|
||||||
|
m_kVct_pkData.reserve(uCapacity);
|
||||||
|
m_kVct_pkFree.reserve(uCapacity);
|
||||||
|
}
|
||||||
|
T* Alloc()
|
||||||
|
{
|
||||||
|
if (m_kVct_pkFree.empty())
|
||||||
|
{
|
||||||
|
T* pkNewData=New();
|
||||||
|
m_kVct_pkData.push_back(pkNewData);
|
||||||
|
++m_uUsedCapacity;
|
||||||
|
return pkNewData;
|
||||||
|
}
|
||||||
|
|
||||||
|
T* pkFreeData=m_kVct_pkFree.back();
|
||||||
|
m_kVct_pkFree.pop_back();
|
||||||
|
return pkFreeData;
|
||||||
|
}
|
||||||
|
void Free(T* pkData)
|
||||||
|
{
|
||||||
|
#ifdef DYNAMIC_POOL_STRICT
|
||||||
|
assert(__IsValidData(pkData));
|
||||||
|
assert(!__IsFreeData(pkData));
|
||||||
|
#endif
|
||||||
|
m_kVct_pkFree.push_back(pkData);
|
||||||
|
}
|
||||||
|
void FreeAll()
|
||||||
|
{
|
||||||
|
m_kVct_pkFree=m_kVct_pkData;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD GetCapacity()
|
||||||
|
{
|
||||||
|
return m_kVct_pkData.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool __IsValidData(T* pkData)
|
||||||
|
{
|
||||||
|
if (m_kVct_pkData.end()==std::find(m_kVct_pkData.begin(), m_kVct_pkData.end(), pkData))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool __IsFreeData(T* pkData)
|
||||||
|
{
|
||||||
|
if (m_kVct_pkFree.end()==std::find(m_kVct_pkFree.begin(), m_kVct_pkFree.end(), pkData))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static T* New()
|
||||||
|
{
|
||||||
|
return (T*)::operator new(sizeof(T));
|
||||||
|
}
|
||||||
|
static void Delete(T* pkData)
|
||||||
|
{
|
||||||
|
::operator delete(pkData);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::vector<T*> m_kVct_pkData;
|
||||||
|
std::vector<T*> m_kVct_pkFree;
|
||||||
|
|
||||||
|
UINT m_uInitCapacity;
|
||||||
|
UINT m_uUsedCapacity;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
class CPooledObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CPooledObject()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual ~CPooledObject()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void * operator new(size_t /*mem_size*/) // PORT: was unsigned int (size_t on ILP32 Win32)
|
||||||
|
{
|
||||||
|
return ms_kPool.Alloc();
|
||||||
|
}
|
||||||
|
|
||||||
|
void operator delete(void* pT)
|
||||||
|
{
|
||||||
|
ms_kPool.Free((T*)pT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void DestroySystem()
|
||||||
|
{
|
||||||
|
ms_kPool.Destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void DeleteAll()
|
||||||
|
{
|
||||||
|
ms_kPool.FreeAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static CDynamicPoolEx<T> ms_kPool;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T> CDynamicPoolEx<T> CPooledObject<T>::ms_kPool;
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
class CDynamicSizePool
|
||||||
|
{
|
||||||
|
#define GETPREVP(p) *(T**)((char*)p+sizeof(T))
|
||||||
|
#define GETNEXTP(p) *(T**)((char*)p+sizeof(T)+sizeof(T*))
|
||||||
|
public:
|
||||||
|
CDynamicSizePool()
|
||||||
|
{
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~CDynamicSizePool()
|
||||||
|
{
|
||||||
|
Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Initialize()
|
||||||
|
{
|
||||||
|
m_nodes = NULL;
|
||||||
|
m_nodeCount = 0;
|
||||||
|
|
||||||
|
m_pFreeList = NULL;
|
||||||
|
m_pUsedList = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetName(const char* c_szName)
|
||||||
|
{
|
||||||
|
m_stName = c_szName;
|
||||||
|
}
|
||||||
|
|
||||||
|
T* Alloc()
|
||||||
|
{
|
||||||
|
void* pnewNode;
|
||||||
|
|
||||||
|
if (m_pFreeList)
|
||||||
|
{
|
||||||
|
pnewNode = m_pFreeList;
|
||||||
|
m_pFreeList = GETNEXTP(m_pFreeList);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pnewNode = AllocNode();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pnewNode)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (!m_pUsedList)
|
||||||
|
{
|
||||||
|
m_pUsedList = pnewNode;
|
||||||
|
GETPREVP(m_pUsedList) = NULL;
|
||||||
|
GETNEXTP(m_pUsedList) = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GETPREVP(m_pUsedList) = (T*) pnewNode;
|
||||||
|
GETNEXTP(pnewNode) = (T*) m_pUsedList;
|
||||||
|
GETPREVP(pnewNode) = NULL;
|
||||||
|
m_pUsedList = pnewNode;
|
||||||
|
}
|
||||||
|
//Tracef("%s Pool Alloc %p\n", m_stName.c_str(), pnewNode);
|
||||||
|
return (T*) pnewNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Free(T * pdata)
|
||||||
|
{
|
||||||
|
void* pfreeNode = (void*) pdata;
|
||||||
|
|
||||||
|
if (pfreeNode == m_pUsedList)
|
||||||
|
{
|
||||||
|
if (NULL != (m_pUsedList = GETNEXTP(m_pUsedList)))
|
||||||
|
GETPREVP(m_pUsedList) = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (GETNEXTP(pfreeNode))
|
||||||
|
GETPREVP(GETNEXTP(pfreeNode)) = GETPREVP(pfreeNode);
|
||||||
|
|
||||||
|
if (GETPREVP(pfreeNode))
|
||||||
|
GETNEXTP(GETPREVP(pfreeNode)) = GETNEXTP(pfreeNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
GETPREVP(pfreeNode) = NULL;
|
||||||
|
GETNEXTP(pfreeNode) = (T*)m_pFreeList;
|
||||||
|
m_pFreeList = pfreeNode;
|
||||||
|
//Tracef("%s Pool Free\n", m_stName.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void FreeAll()
|
||||||
|
{
|
||||||
|
void * pcurNode;
|
||||||
|
void * pnextNode;
|
||||||
|
|
||||||
|
pcurNode = m_pUsedList;
|
||||||
|
|
||||||
|
while (pcurNode)
|
||||||
|
{
|
||||||
|
pnextNode = GETNEXTP(pcurNode);
|
||||||
|
Free(pcurNode);
|
||||||
|
pcurNode = pnextNode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Clear()
|
||||||
|
{
|
||||||
|
void* pcurNode;
|
||||||
|
void* pnextNode;
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
pcurNode = m_pFreeList;
|
||||||
|
while (pcurNode)
|
||||||
|
{
|
||||||
|
pnextNode = GETNEXTP(pcurNode);
|
||||||
|
((T*)pcurNode)->~T();
|
||||||
|
::operator delete(pcurNode);
|
||||||
|
pcurNode = pnextNode;
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
m_pFreeList = NULL;
|
||||||
|
|
||||||
|
pcurNode = m_pUsedList;
|
||||||
|
while (pcurNode)
|
||||||
|
{
|
||||||
|
pnextNode = GETNEXTP(pcurNode);
|
||||||
|
((T*)pcurNode)->~T();
|
||||||
|
::operator delete(pcurNode);
|
||||||
|
pcurNode = pnextNode;
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
m_pUsedList = NULL;
|
||||||
|
//Tracef("%s Pool Clear %d\n", m_stName.c_str(), count);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void* AllocNode()
|
||||||
|
{
|
||||||
|
return ::operator new(sizeof(T)+sizeof(T*)*2);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void * m_nodes;
|
||||||
|
void * m_pFreeList;
|
||||||
|
void * m_pUsedList;
|
||||||
|
|
||||||
|
int m_nodeCount;
|
||||||
|
std::string m_stName;
|
||||||
|
#undef GETNEXTP
|
||||||
|
#undef GETPREVP
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
class CPooledObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CPooledObject()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
virtual ~CPooledObject()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void * operator new(unsigned int mem_size)
|
||||||
|
{
|
||||||
|
return ms_DynamicSizePool.Alloc();
|
||||||
|
}
|
||||||
|
|
||||||
|
void operator delete(void* pT)
|
||||||
|
{
|
||||||
|
ms_DynamicSizePool.Free((T*)pT);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SetPoolName(const char* szPoolName)
|
||||||
|
{
|
||||||
|
ms_DynamicSizePool.SetName(szPoolName);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ClearPool()
|
||||||
|
{
|
||||||
|
ms_DynamicSizePool.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void FreePool()
|
||||||
|
{
|
||||||
|
ms_DynamicSizePool.FreeAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static CDynamicSizePool<T> ms_DynamicSizePool;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T> CDynamicSizePool<T> CPooledObject<T>::ms_DynamicSizePool;
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
template<typename T>
|
||||||
|
class CPoolNode : public T
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CPoolNode()
|
||||||
|
{
|
||||||
|
m_pNext = NULL;
|
||||||
|
m_pPrev = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~CPoolNode()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
CPoolNode<T> * m_pNext;
|
||||||
|
CPoolNode<T> * m_pPrev;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
class CDynamicPool
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef CPoolNode<T> TNode;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CDynamicPool()
|
||||||
|
{
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~CDynamicPool()
|
||||||
|
{
|
||||||
|
assert(m_pFreeList==NULL && "CDynamicPool::~CDynamicPool() - NOT Clear");
|
||||||
|
assert(m_pUsedList==NULL && "CDynamicPool::~CDynamicPool() - NOT Clear");
|
||||||
|
Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Initialize()
|
||||||
|
{
|
||||||
|
m_nodes = NULL;
|
||||||
|
m_nodeCount = 0;
|
||||||
|
|
||||||
|
m_pFreeList = NULL;
|
||||||
|
m_pUsedList = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetName(const char* c_szName)
|
||||||
|
{
|
||||||
|
m_stName = c_szName;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD GetCapacity()
|
||||||
|
{
|
||||||
|
return m_nodeCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
T* Alloc()
|
||||||
|
{
|
||||||
|
TNode* pnewNode;
|
||||||
|
|
||||||
|
if (m_pFreeList)
|
||||||
|
{
|
||||||
|
pnewNode = m_pFreeList;
|
||||||
|
m_pFreeList = m_pFreeList->m_pNext;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pnewNode = AllocNode();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pnewNode)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (!m_pUsedList)
|
||||||
|
{
|
||||||
|
m_pUsedList = pnewNode;
|
||||||
|
m_pUsedList->m_pPrev = m_pUsedList->m_pNext = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_pUsedList->m_pPrev = pnewNode;
|
||||||
|
pnewNode->m_pNext = m_pUsedList;
|
||||||
|
pnewNode->m_pPrev = NULL;
|
||||||
|
m_pUsedList = pnewNode;
|
||||||
|
}
|
||||||
|
//Tracef("%s Pool Alloc %p\n", m_stName.c_str(), pnewNode);
|
||||||
|
return (T*) pnewNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsUsedData(T* pdata)
|
||||||
|
{
|
||||||
|
TNode* pchkNode=(TNode*)pdata;
|
||||||
|
TNode* pcurNode = m_pUsedList;
|
||||||
|
while (pcurNode)
|
||||||
|
{
|
||||||
|
if (pcurNode==pdata)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
pcurNode = pcurNode->m_pNext;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsFreeData(T* pdata)
|
||||||
|
{
|
||||||
|
TNode* pchkNode=(TNode*)pdata;
|
||||||
|
TNode* pcurNode = m_pFreeList;
|
||||||
|
while (pcurNode)
|
||||||
|
{
|
||||||
|
if (pcurNode==pdata)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
pcurNode = pcurNode->m_pNext;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Free(T * pdata)
|
||||||
|
{
|
||||||
|
assert(IsUsedData(pdata));
|
||||||
|
assert(!IsFreeData(pdata));
|
||||||
|
|
||||||
|
TNode* pfreeNode = (TNode*) pdata;
|
||||||
|
|
||||||
|
if (pfreeNode == m_pUsedList)
|
||||||
|
{
|
||||||
|
m_pUsedList = m_pUsedList->m_pNext;
|
||||||
|
if (NULL != m_pUsedList)
|
||||||
|
m_pUsedList->m_pPrev = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (pfreeNode->m_pNext)
|
||||||
|
pfreeNode->m_pNext->m_pPrev = pfreeNode->m_pPrev;
|
||||||
|
|
||||||
|
if (pfreeNode->m_pPrev)
|
||||||
|
pfreeNode->m_pPrev->m_pNext = pfreeNode->m_pNext;
|
||||||
|
}
|
||||||
|
|
||||||
|
pfreeNode->m_pPrev = NULL;
|
||||||
|
pfreeNode->m_pNext = m_pFreeList;
|
||||||
|
m_pFreeList = pfreeNode;
|
||||||
|
//Tracef("%s Pool Free\n", m_stName.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void FreeAll()
|
||||||
|
{
|
||||||
|
TNode * pcurNode;
|
||||||
|
TNode * pnextNode;
|
||||||
|
|
||||||
|
pcurNode = m_pUsedList;
|
||||||
|
|
||||||
|
while (pcurNode)
|
||||||
|
{
|
||||||
|
pnextNode = pcurNode->m_pNext;
|
||||||
|
Free(pcurNode);
|
||||||
|
pcurNode = pnextNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(NULL==m_pUsedList);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Clear()
|
||||||
|
{
|
||||||
|
TNode* pcurNode;
|
||||||
|
TNode* pnextNode;
|
||||||
|
|
||||||
|
DWORD count = 0;
|
||||||
|
|
||||||
|
pcurNode = m_pFreeList;
|
||||||
|
while (pcurNode)
|
||||||
|
{
|
||||||
|
pnextNode = pcurNode->m_pNext;
|
||||||
|
delete pcurNode;
|
||||||
|
pcurNode = pnextNode;
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
m_pFreeList = NULL;
|
||||||
|
|
||||||
|
pcurNode = m_pUsedList;
|
||||||
|
while (pcurNode)
|
||||||
|
{
|
||||||
|
pnextNode = pcurNode->m_pNext;
|
||||||
|
delete pcurNode;
|
||||||
|
pcurNode = pnextNode;
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pUsedList = NULL;
|
||||||
|
|
||||||
|
assert(count==m_nodeCount && "CDynamicPool::Clear()");
|
||||||
|
|
||||||
|
m_nodeCount=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
TNode* AllocNode()
|
||||||
|
{
|
||||||
|
++m_nodeCount;
|
||||||
|
return new TNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
TNode * m_nodes;
|
||||||
|
TNode * m_pFreeList;
|
||||||
|
TNode * m_pUsedList;
|
||||||
|
|
||||||
|
DWORD m_nodeCount;
|
||||||
|
std::string m_stName;
|
||||||
|
};
|
||||||
|
*/
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <d3dx8.h>
|
||||||
|
|
||||||
|
class CRay
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CRay(const D3DXVECTOR3 & v3Start, const D3DXVECTOR3 & v3Dir, float fRayRange) : m_v3Start(v3Start), m_v3Direction(v3Dir)
|
||||||
|
{
|
||||||
|
assert(fRayRange >= 0);
|
||||||
|
m_fRayRange = fRayRange;
|
||||||
|
D3DXVec3Normalize(&m_v3Direction, &m_v3Direction);
|
||||||
|
m_v3End = m_v3Start + fRayRange * m_v3Direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
CRay()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetStartPoint(const D3DXVECTOR3 & v3Start)
|
||||||
|
{
|
||||||
|
m_v3Start = v3Start;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetDirection(const D3DXVECTOR3 & v3Dir, float fRayRange)
|
||||||
|
{
|
||||||
|
assert(fRayRange >= 0);
|
||||||
|
m_v3Direction = v3Dir;
|
||||||
|
D3DXVec3Normalize(&m_v3Direction, &m_v3Direction);
|
||||||
|
m_fRayRange = fRayRange;
|
||||||
|
m_v3End = m_v3Start + m_fRayRange * m_v3Direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GetStartPoint(D3DXVECTOR3 * pv3Start) const
|
||||||
|
{
|
||||||
|
*pv3Start = m_v3Start;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GetDirection(D3DXVECTOR3 * pv3Dir, float * pfRayRange) const
|
||||||
|
{
|
||||||
|
*pv3Dir = m_v3Direction;
|
||||||
|
*pfRayRange = m_fRayRange;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GetEndPoint(D3DXVECTOR3 * pv3End) const
|
||||||
|
{
|
||||||
|
*pv3End = m_v3End;
|
||||||
|
}
|
||||||
|
|
||||||
|
const CRay & operator = (const CRay & rhs)
|
||||||
|
{
|
||||||
|
assert(rhs.m_fRayRange >= 0);
|
||||||
|
m_v3Start = rhs.m_v3Start;
|
||||||
|
m_v3Direction = rhs.m_v3Direction;
|
||||||
|
m_fRayRange = rhs.m_fRayRange;
|
||||||
|
D3DXVec3Normalize(&m_v3Direction, &m_v3Direction);
|
||||||
|
m_v3End = m_v3Start + m_fRayRange * m_v3Direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
D3DXVECTOR3 m_v3Start;
|
||||||
|
D3DXVECTOR3 m_v3End;
|
||||||
|
D3DXVECTOR3 m_v3Direction;
|
||||||
|
float m_fRayRange;
|
||||||
|
};
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
#ifndef __INC_REF_H__
|
||||||
|
#define __INC_REF_H__
|
||||||
|
|
||||||
|
#include "ReferenceObject.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
template<typename T> class CRef
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
struct FClear
|
||||||
|
{
|
||||||
|
void operator() (CRef<T>& rRef)
|
||||||
|
{
|
||||||
|
rRef.Clear();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
CRef() : m_pObject(NULL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
CRef(CReferenceObject* pObject)
|
||||||
|
{
|
||||||
|
m_pObject = NULL;
|
||||||
|
Initialize(pObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
CRef(const CRef& c_rRef)
|
||||||
|
{
|
||||||
|
m_pObject = NULL;
|
||||||
|
Initialize(c_rRef.m_pObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
~CRef()
|
||||||
|
{
|
||||||
|
Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void operator = (CReferenceObject* pObject)
|
||||||
|
{
|
||||||
|
SetPointer(pObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
void operator = (const CRef& c_rRef)
|
||||||
|
{
|
||||||
|
SetPointer(c_rRef.m_pObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Clear()
|
||||||
|
{
|
||||||
|
if (m_pObject)
|
||||||
|
{
|
||||||
|
m_pObject->Release();
|
||||||
|
m_pObject = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsNull() const
|
||||||
|
{
|
||||||
|
return m_pObject == NULL ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetPointer(CReferenceObject* pObject)
|
||||||
|
{
|
||||||
|
CReferenceObject* pOldObject = m_pObject;
|
||||||
|
|
||||||
|
m_pObject = pObject;
|
||||||
|
|
||||||
|
if (m_pObject)
|
||||||
|
m_pObject->AddReference();
|
||||||
|
|
||||||
|
if (pOldObject)
|
||||||
|
pOldObject->Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
T* GetPointer() const
|
||||||
|
{
|
||||||
|
return static_cast<T*>(m_pObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
T* operator->() const
|
||||||
|
{
|
||||||
|
assert(m_pObject != NULL);
|
||||||
|
return static_cast<T*>(m_pObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void Initialize(CReferenceObject* pObject)
|
||||||
|
{
|
||||||
|
assert(m_pObject == NULL);
|
||||||
|
|
||||||
|
m_pObject = pObject;
|
||||||
|
|
||||||
|
if (m_pObject)
|
||||||
|
m_pObject->AddReference();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CReferenceObject* m_pObject;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
class CReferenceObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CReferenceObject();
|
||||||
|
virtual ~CReferenceObject();
|
||||||
|
|
||||||
|
void AddReference();
|
||||||
|
void AddReferenceOnly();
|
||||||
|
void Release();
|
||||||
|
|
||||||
|
int GetReferenceCount();
|
||||||
|
|
||||||
|
bool canDestroy();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void OnConstruct();
|
||||||
|
virtual void OnSelfDestruct();
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_refCount;
|
||||||
|
bool m_destructed;
|
||||||
|
};
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "ReferenceObject.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class CResource : public CReferenceObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef DWORD TType;
|
||||||
|
|
||||||
|
enum EState
|
||||||
|
{
|
||||||
|
STATE_EMPTY,
|
||||||
|
STATE_ERROR,
|
||||||
|
STATE_EXIST,
|
||||||
|
STATE_LOAD,
|
||||||
|
STATE_FREE
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
void Clear();
|
||||||
|
|
||||||
|
static TType StringToType(const char* c_szType);
|
||||||
|
static TType Type();
|
||||||
|
|
||||||
|
void Load();
|
||||||
|
void Reload();
|
||||||
|
int ConvertPathName(const char * c_szPathName, char * pszRetPathName, int retLen);
|
||||||
|
|
||||||
|
virtual bool CreateDeviceObjects();
|
||||||
|
virtual void DestroyDeviceObjects();
|
||||||
|
|
||||||
|
public:
|
||||||
|
CResource(const char* c_szFileName);
|
||||||
|
virtual ~CResource();
|
||||||
|
|
||||||
|
static void SetDeleteImmediately(bool isSet = false);
|
||||||
|
|
||||||
|
// is loaded?
|
||||||
|
bool IsData() const;
|
||||||
|
bool IsEmpty() const;
|
||||||
|
bool IsType(TType type);
|
||||||
|
|
||||||
|
DWORD GetLoadCostMilliSecond() { return m_dwLoadCostMiliiSecond; }
|
||||||
|
//const char * GetFileName() const { return m_pszFileName; }
|
||||||
|
const char * GetFileName() const { return m_stFileName.c_str(); }
|
||||||
|
const std::string& GetFileNameString() const { return m_stFileName; }
|
||||||
|
|
||||||
|
virtual bool OnLoad(int iSize, const void * c_pvBuf) = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void SetFileName(const char* c_szFileName);
|
||||||
|
|
||||||
|
virtual void OnClear() = 0;
|
||||||
|
virtual bool OnIsEmpty() const = 0;
|
||||||
|
virtual bool OnIsType(TType type) = 0;
|
||||||
|
|
||||||
|
virtual void OnConstruct();
|
||||||
|
virtual void OnSelfDestruct();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::string m_stFileName;
|
||||||
|
//char * m_pszFileName;
|
||||||
|
DWORD m_dwLoadCostMiliiSecond;
|
||||||
|
EState me_state;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static bool ms_bDeleteImmediately;
|
||||||
|
};
|
||||||
@@ -0,0 +1,188 @@
|
|||||||
|
// SkyBox.h: interface for the CSkyBox class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if !defined(AFX_SKYBOX_H__AB5049E1_8F1C_4C35_9406_45EC7EF4AD1B__INCLUDED_)
|
||||||
|
#define AFX_SKYBOX_H__AB5049E1_8F1C_4C35_9406_45EC7EF4AD1B__INCLUDED_
|
||||||
|
|
||||||
|
#if _MSC_VER > 1000
|
||||||
|
#pragma once
|
||||||
|
#endif // _MSC_VER > 1000
|
||||||
|
|
||||||
|
#include "GrpBase.h"
|
||||||
|
#include "GrpScreen.h"
|
||||||
|
#include "GrpImageInstance.h"
|
||||||
|
#include "ColorTransitionHelper.h"
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
typedef struct SColor
|
||||||
|
{
|
||||||
|
SColor(float _r = 0.0f, float _g = 0.0f, float _b = 0.0f, float _a = 0.0f) : r(_r), g(_g), b(_b), a(_a){}
|
||||||
|
float r, g, b, a;
|
||||||
|
} TColor;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
TColor m_FirstColor;
|
||||||
|
TColor m_SecondColor;
|
||||||
|
}TGradientColor;
|
||||||
|
|
||||||
|
typedef std::vector<TGradientColor> TVectorGradientColor;
|
||||||
|
typedef TVectorGradientColor::iterator TVectorGradientIterator;
|
||||||
|
|
||||||
|
class CSkyObjectQuad
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CSkyObjectQuad();
|
||||||
|
virtual ~CSkyObjectQuad();
|
||||||
|
|
||||||
|
void Clear(const unsigned char & c_rucNumVertex,
|
||||||
|
const float & c_rfRed,
|
||||||
|
const float & c_rfGreen,
|
||||||
|
const float & c_rfBlue,
|
||||||
|
const float & c_rfAlpha);
|
||||||
|
void SetSrcColor(const unsigned char & c_rucNumVertex,
|
||||||
|
const float & c_rfRed,
|
||||||
|
const float & c_rfGreen,
|
||||||
|
const float & c_rfBlue,
|
||||||
|
const float & c_rfAlpha);
|
||||||
|
void SetTransition(const unsigned char & c_rucNumVertex,
|
||||||
|
const float & c_rfRed,
|
||||||
|
const float & c_rfGreen,
|
||||||
|
const float & c_rfBlue,
|
||||||
|
const float & c_rfAlpha,
|
||||||
|
DWORD dwDuration);
|
||||||
|
|
||||||
|
void SetVertex(const unsigned char & c_rucNumVertex, const TPDTVertex & c_rPDTVertex);
|
||||||
|
|
||||||
|
void StartTransition();
|
||||||
|
bool Update();
|
||||||
|
void Render();
|
||||||
|
|
||||||
|
private:
|
||||||
|
TPDTVertex m_Vertex[4];
|
||||||
|
TIndex m_Indices[4]; // 인덱스 버퍼...
|
||||||
|
CColorTransitionHelper m_Helper[4];
|
||||||
|
};
|
||||||
|
|
||||||
|
class CSkyObject : public CScreen
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
SKY_RENDER_MODE_DEFAULT, // = SKY_RENDER_MODE_TEXTURE
|
||||||
|
SKY_RENDER_MODE_DIFFUSE,
|
||||||
|
SKY_RENDER_MODE_TEXTURE,
|
||||||
|
SKY_RENDER_MODE_MODULATE,
|
||||||
|
SKY_RENDER_MODE_MODULATE2X,
|
||||||
|
SKY_RENDER_MODE_MODULATE4X,
|
||||||
|
};
|
||||||
|
|
||||||
|
CSkyObject();
|
||||||
|
virtual ~CSkyObject();
|
||||||
|
|
||||||
|
virtual void Destroy() = 0;
|
||||||
|
|
||||||
|
virtual void Render() = 0;
|
||||||
|
virtual void Update() = 0;
|
||||||
|
virtual void StartTransition();
|
||||||
|
|
||||||
|
void SetRenderMode(unsigned char ucRenderMode) { m_ucRenderMode = ucRenderMode; }
|
||||||
|
|
||||||
|
const bool & isTransitionStarted() { return m_bTransitionStarted; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
CGraphicImageInstance * GenerateTexture(const char * szfilename);
|
||||||
|
void DeleteTexture(CGraphicImageInstance * pGraphicImageInstance);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
// 타입 정의
|
||||||
|
|
||||||
|
typedef std::vector<CSkyObjectQuad> TSkyObjectQuadVector;
|
||||||
|
typedef TSkyObjectQuadVector::iterator TSkyObjectQuadIterator;
|
||||||
|
|
||||||
|
typedef struct CSkyBox
|
||||||
|
{
|
||||||
|
void StartTransition();
|
||||||
|
bool Update();
|
||||||
|
void Render();
|
||||||
|
std::string m_strfacename;
|
||||||
|
std::string m_strFaceTextureFileName;
|
||||||
|
TSkyObjectQuadVector m_SkyObjectQuadVector;
|
||||||
|
}TSkyObjectFace;
|
||||||
|
|
||||||
|
typedef std::map <std::string, CGraphicImageInstance*> TGraphicImageInstanceMap;
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// 구름...
|
||||||
|
TSkyObjectFace m_FaceCloud; // 구름 일단 한장...
|
||||||
|
D3DXMATRIX m_matWorldCloud, m_matTranslationCloud, m_matTextureCloud;
|
||||||
|
D3DXVECTOR3 m_v3PositionCloud;
|
||||||
|
float m_fCloudScaleX, m_fCloudScaleY, m_fCloudHeight;
|
||||||
|
float m_fCloudTextureScaleX, m_fCloudTextureScaleY;
|
||||||
|
float m_fCloudScrollSpeedU, m_fCloudScrollSpeedV;
|
||||||
|
float m_fCloudPositionU, m_fCloudPositionV;
|
||||||
|
|
||||||
|
DWORD m_dwlastTime;
|
||||||
|
|
||||||
|
// 스카이 박스 이미지...
|
||||||
|
TGraphicImageInstanceMap m_GraphicImageInstanceMap;
|
||||||
|
|
||||||
|
// Transform...
|
||||||
|
D3DXMATRIX m_matWorld, m_matTranslation;
|
||||||
|
D3DXVECTOR3 m_v3Position;
|
||||||
|
float m_fScaleX, m_fScaleY, m_fScaleZ;
|
||||||
|
|
||||||
|
// 랜더링 관련... 임시 변수..
|
||||||
|
unsigned char m_ucRenderMode;
|
||||||
|
|
||||||
|
std::string m_strCurTime;
|
||||||
|
bool m_bTransitionStarted;
|
||||||
|
bool m_bSkyMatrixUpdated;
|
||||||
|
|
||||||
|
CGraphicImageInstance m_CloudAlphaImageInstance;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CSkyBox : public CSkyObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CSkyBox();
|
||||||
|
virtual ~CSkyBox();
|
||||||
|
|
||||||
|
void Update();
|
||||||
|
void Render();
|
||||||
|
void RenderCloud();
|
||||||
|
|
||||||
|
void Destroy();
|
||||||
|
void Unload();
|
||||||
|
|
||||||
|
void SetSkyBoxScale(const D3DXVECTOR3 & c_rv3Scale);
|
||||||
|
void SetGradientLevel(BYTE byUpper, BYTE byLower);
|
||||||
|
void SetFaceTexture( const char* c_szFileName, int iFaceIndex );
|
||||||
|
void SetCloudTexture(const char * c_szFileName);
|
||||||
|
void SetCloudScale(const D3DXVECTOR2 & c_rv2CloudScale);
|
||||||
|
void SetCloudHeight(float fHeight);
|
||||||
|
void SetCloudTextureScale(const D3DXVECTOR2 & c_rv2CloudTextureScale);
|
||||||
|
void SetCloudScrollSpeed(const D3DXVECTOR2 & c_rv2CloudScrollSpeed);
|
||||||
|
void SetCloudColor(const TGradientColor & c_rColor, const TGradientColor & c_rNextColor, const DWORD & dwTransitionTime);
|
||||||
|
void Refresh();
|
||||||
|
void SetSkyColor(const TVectorGradientColor & c_rColorVector, const TVectorGradientColor & c_rNextColorVector, long lTransitionTime);
|
||||||
|
void StartTransition();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void SetSkyObjectQuadVertical(TSkyObjectQuadVector * pSkyObjectQuadVector, const D3DXVECTOR2 * c_pv2QuadPoints);
|
||||||
|
void SetSkyObjectQuadHorizon(TSkyObjectQuadVector * pSkyObjectQuadVector, const D3DXVECTOR3 * c_pv3QuadPoints);
|
||||||
|
|
||||||
|
//void UpdateSkyFaceQuadTransform(D3DXVECTOR3 * c_pv3QuadPoints);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
unsigned char m_ucVirticalGradientLevelUpper;
|
||||||
|
unsigned char m_ucVirticalGradientLevelLower;
|
||||||
|
TSkyObjectFace m_Faces[6];
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // !defined(AFX_SKYBOX_H__AB5049E1_8F1C_4C35_9406_45EC7EF4AD1B__INCLUDED_)
|
||||||
@@ -0,0 +1,142 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||||
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define _WIN32_DCOM
|
||||||
|
|
||||||
|
#pragma warning(disable:4710) // not inlined
|
||||||
|
#pragma warning(disable:4786) // character 255 넘어가는거 끄기
|
||||||
|
#pragma warning(disable:4244) // type conversion possible lose of data
|
||||||
|
|
||||||
|
#pragma warning(disable:4018)
|
||||||
|
#pragma warning(disable:4245)
|
||||||
|
#pragma warning(disable:4512)
|
||||||
|
#pragma warning(disable:4201)
|
||||||
|
|
||||||
|
#if _MSC_VER >= 1400
|
||||||
|
#pragma warning(disable:4201 4512 4238 4239)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <d3d8.h>
|
||||||
|
#include <d3dx8.h>
|
||||||
|
|
||||||
|
#define DIRECTINPUT_VERSION 0x0800
|
||||||
|
|
||||||
|
#include <dinput.h>
|
||||||
|
|
||||||
|
#pragma warning ( disable : 4201 )
|
||||||
|
#include <mmsystem.h>
|
||||||
|
#pragma warning ( default : 4201 )
|
||||||
|
#include <process.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <direct.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
|
#pragma comment(lib, "winmm.lib")
|
||||||
|
#pragma comment(lib, "d3d8.lib")
|
||||||
|
#pragma comment(lib, "d3dx8.lib")
|
||||||
|
|
||||||
|
#include "../EterBase/StdAfx.h"
|
||||||
|
#include "../EterBase/Debug.h"
|
||||||
|
#include "../EterLocale/CodePageId.h"
|
||||||
|
|
||||||
|
#ifndef VC_EXTRALEAN
|
||||||
|
#include <winsock.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
#include "Pool.h"
|
||||||
|
#include "Dynamic.h"
|
||||||
|
#include "Event.h"
|
||||||
|
#include "FuncObject.h"
|
||||||
|
#include "ReferenceObject.h"
|
||||||
|
#include "Ref.h"
|
||||||
|
|
||||||
|
#include "Util.h"
|
||||||
|
#include "TextFileLoader.h"
|
||||||
|
#include "parser.h"
|
||||||
|
|
||||||
|
#include "Resource.h"
|
||||||
|
#include "ResourceManager.h"
|
||||||
|
|
||||||
|
#include "MSWindow.h"
|
||||||
|
#include "MSApplication.h"
|
||||||
|
#include "Mutex.h"
|
||||||
|
#include "Thread.h"
|
||||||
|
|
||||||
|
#include "GrpBase.h"
|
||||||
|
|
||||||
|
#include "GrpDIB.h"
|
||||||
|
#include "GrpMath.h"
|
||||||
|
#include "GrpDevice.h"
|
||||||
|
|
||||||
|
#include "CollisionData.h"
|
||||||
|
#include "GrpCollisionObject.h"
|
||||||
|
#include "GrpScreen.h"
|
||||||
|
#include "CullingManager.h"
|
||||||
|
|
||||||
|
// Attribute
|
||||||
|
#include "AttributeData.h"
|
||||||
|
#include "AttributeInstance.h"
|
||||||
|
|
||||||
|
#include "GrpObjectInstance.h"
|
||||||
|
#include "GrpRatioInstance.h"
|
||||||
|
|
||||||
|
#include "GrpD3DXBuffer.h"
|
||||||
|
|
||||||
|
#include "GrpTexture.h"
|
||||||
|
#include "GrpImageTexture.h"
|
||||||
|
#include "GrpFontTexture.h"
|
||||||
|
|
||||||
|
#include "GrpText.h"
|
||||||
|
#include "GrpImage.h"
|
||||||
|
#include "GrpSubImage.h"
|
||||||
|
|
||||||
|
#include "GrpIndexBuffer.h"
|
||||||
|
#include "GrpVertexBuffer.h"
|
||||||
|
#include "GrpVertexBufferStatic.h"
|
||||||
|
#include "GrpVertexBufferDynamic.h"
|
||||||
|
#include "GrpVertexShader.h"
|
||||||
|
#include "GrpPixelShader.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "GrpShadowTexture.h"
|
||||||
|
#include "GrpImageInstance.h"
|
||||||
|
#include "GrpExpandedImageInstance.h"
|
||||||
|
#include "GrpTextInstance.h"
|
||||||
|
#include "GrpLightManager.h"
|
||||||
|
|
||||||
|
#include "TargaResource.h"
|
||||||
|
|
||||||
|
#include "NetDevice.h"
|
||||||
|
#include "NetAddress.h"
|
||||||
|
// #include "NetStream.h"
|
||||||
|
#include "NetPacketHeaderMap.h"
|
||||||
|
#include "NetDatagramSender.h"
|
||||||
|
#include "NetDatagramReceiver.h"
|
||||||
|
|
||||||
|
#include "Input.h"
|
||||||
|
#include "IME.h"
|
||||||
|
|
||||||
|
#include "PathStack.h"
|
||||||
|
//#include "Property.h"
|
||||||
|
|
||||||
|
#include "Profiler.h"
|
||||||
|
|
||||||
|
#include "StateManager.h"
|
||||||
|
|
||||||
|
#include "ColorTransitionHelper.h"
|
||||||
|
#include "LensFlare.h"
|
||||||
|
#include "ScreenFilter.h"
|
||||||
|
#include "EnvironmentMap.h"
|
||||||
|
|
||||||
|
#include "lineintersect_utils.h"
|
||||||
|
|
||||||
|
#include "Decal.h"
|
||||||
|
*/
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
#ifndef __INC_METIN_II_TEXTFILELOADER_H__
|
||||||
|
#define __INC_METIN_II_TEXTFILELOADER_H__
|
||||||
|
|
||||||
|
#include "../EterBase/FileLoader.h"
|
||||||
|
#include "../EterBase/MappedFile.h"
|
||||||
|
#include "../EterLib/Util.h"
|
||||||
|
#include "../EterLib/Pool.h"
|
||||||
|
|
||||||
|
class CTextFileLoader
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef struct SGroupNode
|
||||||
|
{
|
||||||
|
static DWORD GenNameKey(const char* c_szGroupName, UINT uGroupNameLen);
|
||||||
|
|
||||||
|
void SetGroupName(const std::string& c_rstGroupName);
|
||||||
|
bool IsGroupNameKey(DWORD dwGroupNameKey);
|
||||||
|
|
||||||
|
const std::string& GetGroupName();
|
||||||
|
|
||||||
|
CTokenVector* GetTokenVector(const std::string& c_rstGroupName);
|
||||||
|
bool IsExistTokenVector(const std::string& c_rstGroupName);
|
||||||
|
void InsertTokenVector(const std::string& c_rstGroupName, const CTokenVector& c_rkVct_stToken);
|
||||||
|
|
||||||
|
DWORD m_dwGroupNameKey;
|
||||||
|
std::string m_strGroupName;
|
||||||
|
|
||||||
|
std::map<DWORD, CTokenVector> m_kMap_dwKey_kVct_stToken;
|
||||||
|
|
||||||
|
SGroupNode * pParentNode;
|
||||||
|
std::vector<SGroupNode*> ChildNodeVector;
|
||||||
|
|
||||||
|
static SGroupNode* New();
|
||||||
|
static void Delete(SGroupNode* pkNode);
|
||||||
|
|
||||||
|
static void DestroySystem();
|
||||||
|
static CDynamicPool<SGroupNode> ms_kPool;
|
||||||
|
} TGroupNode;
|
||||||
|
|
||||||
|
typedef std::vector<TGroupNode*> TGroupNodeVector;
|
||||||
|
|
||||||
|
class CGotoChild
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CGotoChild(CTextFileLoader * pOwner, const char * c_szKey) : m_pOwner(pOwner)
|
||||||
|
{
|
||||||
|
m_pOwner->SetChildNode(c_szKey);
|
||||||
|
}
|
||||||
|
CGotoChild(CTextFileLoader * pOwner, DWORD dwIndex) : m_pOwner(pOwner)
|
||||||
|
{
|
||||||
|
m_pOwner->SetChildNode(dwIndex);
|
||||||
|
}
|
||||||
|
~CGotoChild()
|
||||||
|
{
|
||||||
|
m_pOwner->SetParentNode();
|
||||||
|
}
|
||||||
|
|
||||||
|
CTextFileLoader * m_pOwner;
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
static void DestroySystem();
|
||||||
|
|
||||||
|
static void SetCacheMode();
|
||||||
|
|
||||||
|
static CTextFileLoader* Cache(const char* c_szFileName);
|
||||||
|
|
||||||
|
public:
|
||||||
|
CTextFileLoader();
|
||||||
|
virtual ~CTextFileLoader();
|
||||||
|
|
||||||
|
void Destroy();
|
||||||
|
|
||||||
|
bool Load(const char * c_szFileName);
|
||||||
|
const char * GetFileName();
|
||||||
|
|
||||||
|
bool IsEmpty();
|
||||||
|
|
||||||
|
void SetTop();
|
||||||
|
DWORD GetChildNodeCount();
|
||||||
|
BOOL SetChildNode(const char * c_szKey);
|
||||||
|
BOOL SetChildNode(const std::string & c_rstrKeyHead, DWORD dwIndex);
|
||||||
|
BOOL SetChildNode(DWORD dwIndex);
|
||||||
|
BOOL SetParentNode();
|
||||||
|
BOOL GetCurrentNodeName(std::string * pstrName);
|
||||||
|
|
||||||
|
BOOL IsToken(const std::string & c_rstrKey);
|
||||||
|
BOOL GetTokenVector(const std::string & c_rstrKey, CTokenVector ** ppTokenVector);
|
||||||
|
BOOL GetTokenBoolean(const std::string & c_rstrKey, BOOL * pData);
|
||||||
|
BOOL GetTokenByte(const std::string & c_rstrKey, BYTE * pData);
|
||||||
|
BOOL GetTokenWord(const std::string & c_rstrKey, WORD * pData);
|
||||||
|
BOOL GetTokenInteger(const std::string & c_rstrKey, int * pData);
|
||||||
|
BOOL GetTokenDoubleWord(const std::string & c_rstrKey, DWORD * pData);
|
||||||
|
BOOL GetTokenFloat(const std::string & c_rstrKey, float * pData);
|
||||||
|
BOOL GetTokenVector2(const std::string & c_rstrKey, D3DXVECTOR2 * pVector2);
|
||||||
|
BOOL GetTokenVector3(const std::string & c_rstrKey, D3DXVECTOR3 * pVector3);
|
||||||
|
BOOL GetTokenVector4(const std::string & c_rstrKey, D3DXVECTOR4 * pVector4);
|
||||||
|
|
||||||
|
BOOL GetTokenPosition(const std::string & c_rstrKey, D3DXVECTOR3 * pVector);
|
||||||
|
BOOL GetTokenQuaternion(const std::string & c_rstrKey, D3DXQUATERNION * pQ);
|
||||||
|
BOOL GetTokenDirection(const std::string & c_rstrKey, D3DVECTOR * pVector);
|
||||||
|
BOOL GetTokenColor(const std::string & c_rstrKey, D3DXCOLOR * pColor);
|
||||||
|
BOOL GetTokenColor(const std::string & c_rstrKey, D3DCOLORVALUE * pColor);
|
||||||
|
BOOL GetTokenString(const std::string & c_rstrKey, std::string * pString);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void __DestroyGroupNodeVector();
|
||||||
|
|
||||||
|
bool LoadGroup(TGroupNode * pGroupNode);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::string m_strFileName;
|
||||||
|
|
||||||
|
char* m_acBufData;
|
||||||
|
DWORD m_dwBufSize;
|
||||||
|
DWORD m_dwBufCapacity;
|
||||||
|
|
||||||
|
DWORD m_dwcurLineIndex;
|
||||||
|
|
||||||
|
CMemoryTextFileLoader m_textFileLoader;
|
||||||
|
|
||||||
|
TGroupNode m_GlobalNode;
|
||||||
|
TGroupNode * m_pcurNode;
|
||||||
|
|
||||||
|
std::vector<SGroupNode*> m_kVct_pkNode;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static std::map<DWORD, CTextFileLoader*> ms_kMap_dwNameKey_pkTextFileLoader;
|
||||||
|
static bool ms_isCacheMode;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
#include "../EterBase/FileLoader.h"
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include <d3dx8.h>
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
class CTransitor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CTransitor() {}
|
||||||
|
~CTransitor() {}
|
||||||
|
|
||||||
|
void SetActive(BOOL bActive = TRUE)
|
||||||
|
{
|
||||||
|
m_bActivated = bActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL isActive()
|
||||||
|
{
|
||||||
|
return m_bActivated;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL isActiveTime(float fcurTime)
|
||||||
|
{
|
||||||
|
if (fcurTime >= m_fEndTime)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD GetID()
|
||||||
|
{
|
||||||
|
return m_dwID;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetID(DWORD dwID)
|
||||||
|
{
|
||||||
|
m_dwID = dwID;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetSourceValue(const T & c_rSourceValue)
|
||||||
|
{
|
||||||
|
m_SourceValue = c_rSourceValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetTransition(const T & c_rSourceValue, const T & c_rTargetValue, float fStartTime, float fBlendTime)
|
||||||
|
{
|
||||||
|
m_SourceValue = c_rSourceValue;
|
||||||
|
m_TargetValue = c_rTargetValue;
|
||||||
|
m_fStartTime = fStartTime;
|
||||||
|
m_fEndTime = fStartTime + fBlendTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL GetValue(float fcurTime, T * pValue)
|
||||||
|
{
|
||||||
|
if (fcurTime <= m_fStartTime)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
float fPercentage = (fcurTime - m_fStartTime) / (m_fEndTime - m_fStartTime);
|
||||||
|
*pValue = m_SourceValue + (m_TargetValue - m_SourceValue) * fPercentage;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
DWORD m_dwID; // Public Transitor ID
|
||||||
|
|
||||||
|
BOOL m_bActivated; // Have been started to blend?
|
||||||
|
float m_fStartTime;
|
||||||
|
float m_fEndTime;
|
||||||
|
|
||||||
|
T m_SourceValue;
|
||||||
|
T m_TargetValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef CTransitor<float> TTransitorFloat;
|
||||||
|
typedef CTransitor<D3DXVECTOR3> TTransitorVector3;
|
||||||
|
typedef CTransitor<D3DXCOLOR> TTransitorColor;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void PrintfTabs(FILE * File, int iTabCount, const char * c_szString, ...);
|
||||||
|
|
||||||
|
|
||||||
|
//typedef CTokenVector TTokenVector;
|
||||||
|
|
||||||
|
extern bool LoadTextData(const char * c_szFileName, CTokenMap & rstTokenMap);
|
||||||
|
extern bool LoadMultipleTextData(const char * c_szFileName, CTokenVectorMap & rstTokenVectorMap);
|
||||||
|
|
||||||
|
extern D3DXVECTOR3 TokenToVector(CTokenVector & rVector);
|
||||||
|
extern D3DXCOLOR TokenToColor(CTokenVector & rVector);
|
||||||
|
|
||||||
|
#define GOTO_CHILD_NODE(TextFileLoader, Index) CTextFileLoader::CGotoChild Child(TextFileLoader, Index);
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
extern int CALLBACK EnumFontFamExProc(CONST LOGFONT* plogFont, CONST TEXTMETRIC* textMetric, DWORD dwWord, LPARAM lParam);
|
||||||
|
extern int GetCharsetFromCodePage(WORD codePage);
|
||||||
|
extern const char* GetFontFaceFromCodePageNT(WORD codePage);
|
||||||
|
extern const char* GetFontFaceFromCodePage9x(WORD codePage);
|
||||||
|
extern DWORD GetDefaultCodePage();
|
||||||
|
extern const char * GetDefaultFontFace();
|
||||||
|
extern const char* GetFontFaceFromCodePage(WORD codePage);
|
||||||
|
extern void SetDefaultFontFace(const char* fontFace);
|
||||||
|
extern bool SetDefaultCodePage(DWORD codePage);
|
||||||
|
extern void base64_decode(const char * str,char * resultStr);
|
||||||
|
|
||||||
|
extern DWORD GetMaxTextureWidth();
|
||||||
|
extern DWORD GetMaxTextureHeight();
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
#ifndef __INC_SCRIPT_PARSER_H__
|
||||||
|
#define __INC_SCRIPT_PARSER_H__
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace script
|
||||||
|
{
|
||||||
|
typedef struct SArgumet
|
||||||
|
{
|
||||||
|
SArgumet(const std::string& c_stName, const std::string& c_stValue)
|
||||||
|
{
|
||||||
|
strName = c_stName;
|
||||||
|
strValue = c_stValue;
|
||||||
|
}
|
||||||
|
SArgumet(const SArgumet& c_arg)
|
||||||
|
{
|
||||||
|
strName = c_arg.strName;
|
||||||
|
strValue = c_arg.strValue;
|
||||||
|
}
|
||||||
|
void operator=(const SArgumet& c_arg)
|
||||||
|
{
|
||||||
|
strName = c_arg.strName;
|
||||||
|
strValue = c_arg.strValue;
|
||||||
|
}
|
||||||
|
std::string strName;
|
||||||
|
std::string strValue;
|
||||||
|
} TArg;
|
||||||
|
|
||||||
|
typedef std::list<TArg> TArgList;
|
||||||
|
|
||||||
|
typedef struct SCmd
|
||||||
|
{
|
||||||
|
std::string name;
|
||||||
|
TArgList argList;
|
||||||
|
|
||||||
|
SCmd()
|
||||||
|
{}
|
||||||
|
SCmd(const SCmd& c_cmd)
|
||||||
|
{
|
||||||
|
name = c_cmd.name;
|
||||||
|
argList = c_cmd.argList;
|
||||||
|
}
|
||||||
|
void operator=(const SCmd& c_cmd)
|
||||||
|
{
|
||||||
|
name = c_cmd.name;
|
||||||
|
argList = c_cmd.argList;
|
||||||
|
}
|
||||||
|
} TCmd;
|
||||||
|
|
||||||
|
class Group
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Group();
|
||||||
|
~Group();
|
||||||
|
|
||||||
|
public:
|
||||||
|
/** 스트링으로 부터 스크립트 그룹을 만든다.
|
||||||
|
*
|
||||||
|
* 실패하면 GetError 메소드로 확인할 수 있다.
|
||||||
|
*
|
||||||
|
* @param stSource 이 스트링으로 부터 그룹이 만들어 진다.
|
||||||
|
* @return 성공시 true, 실패하면 false
|
||||||
|
*/
|
||||||
|
bool Create(const std::string & stSource);
|
||||||
|
|
||||||
|
/** 명령어를 받는 메소드
|
||||||
|
*
|
||||||
|
* @param cmd 성공시에 이 구조체로 명령어가 복사 된다.
|
||||||
|
* @return 명령어가 남아 있다면 true, 없다면 false
|
||||||
|
*/
|
||||||
|
bool GetCmd(TCmd & cmd);
|
||||||
|
|
||||||
|
/*
|
||||||
|
명령어를 가져오되 꺼내지는 않는다.
|
||||||
|
*/
|
||||||
|
bool ReadCmd(TCmd & cmd);
|
||||||
|
|
||||||
|
/** 에러를 출력 받는 메소드
|
||||||
|
*
|
||||||
|
* @return stError 이 곳으로 에러가 출력 된다.
|
||||||
|
*/
|
||||||
|
std::string & GetError();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void SetError(const char *str);
|
||||||
|
bool GetArg(const char * c_atr_base, int arg_len, TArgList & argList);
|
||||||
|
|
||||||
|
std::string m_stError;
|
||||||
|
std::list<TCmd> m_cmdList;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define CP_874 874 // Thai
|
||||||
|
#define CP_THAI CP_874
|
||||||
|
|
||||||
|
#define CP_932 932 // Japanese
|
||||||
|
#define CP_JAPANESE CP_932
|
||||||
|
|
||||||
|
#define CP_936 936 // Chinese(Simplefied)
|
||||||
|
#define CP_CHINESE_SIMPLE CP_936
|
||||||
|
|
||||||
|
#define CP_949 949 // Hangeul
|
||||||
|
#define CP_HANGUL CP_949
|
||||||
|
|
||||||
|
#define CP_950 950 // Chinese(Traditional)
|
||||||
|
#define CP_CHINESE_TRAD CP_950
|
||||||
|
|
||||||
|
#define CP_1250 1250 // Middle and East Europe
|
||||||
|
#define CP_EASTEUROPE CP_1250
|
||||||
|
|
||||||
|
#define CP_1251 1251 // Cyrillic
|
||||||
|
#define CP_CYRILLIC CP_1251
|
||||||
|
|
||||||
|
#define CP_1252 1252 // Latin
|
||||||
|
#define CP_LATIN CP_1252
|
||||||
|
|
||||||
|
#define CP_1253 1253 // Greek
|
||||||
|
#define CP_GREEK CP_1253
|
||||||
|
|
||||||
|
#define CP_1254 1254 // Turkish
|
||||||
|
#define CP_TURKISH CP_1254
|
||||||
|
|
||||||
|
#define CP_1255 1255 // Hebrew
|
||||||
|
#define CP_HEBREW CP_1255
|
||||||
|
|
||||||
|
#define CP_1256 1256 // Aralic
|
||||||
|
#define CP_ARABIC CP_1256
|
||||||
|
|
||||||
|
#define CP_1257 1257 // Baltic
|
||||||
|
#define CP_BALTIC CP_1257
|
||||||
|
|
||||||
|
#define CP_1258 1258 // Vietnamese
|
||||||
|
#define CP_VIETNAMESE CP_1258
|
||||||
|
|
||||||
|
#define CP_65001 65001 // UTF-8
|
||||||
|
//#define CP_UTF8 65001 // UTF-8 translation
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
// stdafx.h : include file for standard system include files,
|
||||||
|
// or project specific include files that are used frequently, but
|
||||||
|
// are changed infrequently
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "CodePageId.h"
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||||
|
|
||||||
|
//#include <crtdbg.h>
|
||||||
|
#include <windows.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "../EterBase/StdAfx.h"
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
#ifndef __INC_ETERPACKLIB_MD5_H__
|
||||||
|
#define __INC_ETERPACKLIB_MD5_H__
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
***********************************************************************
|
||||||
|
|
||||||
|
** md5.h -- header file for implementation of MD5 **
|
||||||
|
|
||||||
|
** RSA Data Security, Inc. MD5 Message-Digest Algorithm **
|
||||||
|
|
||||||
|
** Created: 2/17/90 RLR **
|
||||||
|
|
||||||
|
** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version **
|
||||||
|
|
||||||
|
** Revised (for MD5): RLR 4/27/91 **
|
||||||
|
|
||||||
|
** -- G modified to have y&~z instead of y&z **
|
||||||
|
|
||||||
|
** -- FF, GG, HH modified to add in last register done **
|
||||||
|
|
||||||
|
** -- Access pattern: round 2 works mod 5, round 3 works mod 3 **
|
||||||
|
|
||||||
|
** -- distinct additive constant for each step **
|
||||||
|
|
||||||
|
** -- round 4 added, working mod 7 **
|
||||||
|
|
||||||
|
***********************************************************************
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
***********************************************************************
|
||||||
|
|
||||||
|
** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. **
|
||||||
|
|
||||||
|
** **
|
||||||
|
|
||||||
|
** License to copy and use this software is granted provided that **
|
||||||
|
|
||||||
|
** it is identified as the "RSA Data Security, Inc. MD5 Message- **
|
||||||
|
|
||||||
|
** Digest Algorithm" in all material mentioning or referencing this **
|
||||||
|
|
||||||
|
** software or this function. **
|
||||||
|
|
||||||
|
** **
|
||||||
|
|
||||||
|
** License is also granted to make and use derivative works **
|
||||||
|
|
||||||
|
** provided that such works are identified as "derived from the RSA **
|
||||||
|
|
||||||
|
** Data Security, Inc. MD5 Message-Digest Algorithm" in all **
|
||||||
|
|
||||||
|
** material mentioning or referencing the derived work. **
|
||||||
|
|
||||||
|
** **
|
||||||
|
|
||||||
|
** RSA Data Security, Inc. makes no representations concerning **
|
||||||
|
|
||||||
|
** either the merchantability of this software or the suitability **
|
||||||
|
|
||||||
|
** of this software for any particular purpose. It is provided "as **
|
||||||
|
|
||||||
|
** is" without express or implied warranty of any kind. **
|
||||||
|
|
||||||
|
** **
|
||||||
|
|
||||||
|
** These notices must be retained in any copies of any part of this **
|
||||||
|
|
||||||
|
** documentation and/or software. **
|
||||||
|
|
||||||
|
***********************************************************************
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* typedef a 32-bit type */
|
||||||
|
|
||||||
|
typedef unsigned long int UINT4;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Data structure for MD5 (Message-Digest) computation */
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
|
||||||
|
UINT4 i[2]; /* number of _bits_ handled mod 2^64 */
|
||||||
|
|
||||||
|
UINT4 buf[4]; /* scratch buffer */
|
||||||
|
|
||||||
|
unsigned char in[64]; /* input buffer */
|
||||||
|
|
||||||
|
unsigned char digest[16]; /* actual digest after MD5Final call */
|
||||||
|
|
||||||
|
} MD5_CTX;
|
||||||
|
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void MD5Init (MD5_CTX *);
|
||||||
|
|
||||||
|
void MD5Update (MD5_CTX *,unsigned char *,unsigned int);
|
||||||
|
|
||||||
|
void MD5Final (MD5_CTX *);
|
||||||
|
|
||||||
|
void MD5Transform(UINT4 *,UINT4 *);
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
***********************************************************************
|
||||||
|
|
||||||
|
** End of md5.h **
|
||||||
|
|
||||||
|
******************************** (cut) ********************************
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
// AreaLoaderThread.h: interface for the CAreaLoaderThread class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if !defined(AFX_AREALOADERTHREAD_H__E43FBE42_42F4_4F0E_B9DA_D7B7C5EA0753__INCLUDED_)
|
||||||
|
#define AFX_AREALOADERTHREAD_H__E43FBE42_42F4_4F0E_B9DA_D7B7C5EA0753__INCLUDED_
|
||||||
|
|
||||||
|
#if _MSC_VER > 1000
|
||||||
|
#pragma once
|
||||||
|
#endif // _MSC_VER > 1000
|
||||||
|
|
||||||
|
#include "../EterLib/Mutex.h"
|
||||||
|
|
||||||
|
class CTerrain;
|
||||||
|
class CArea;
|
||||||
|
|
||||||
|
class TEMP_CAreaLoaderThread
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TEMP_CAreaLoaderThread();
|
||||||
|
virtual ~TEMP_CAreaLoaderThread();
|
||||||
|
|
||||||
|
bool Create(void * arg);
|
||||||
|
void Shutdown();
|
||||||
|
|
||||||
|
void Request(CTerrain * pTerrain);
|
||||||
|
|
||||||
|
bool Fetch(CTerrain ** ppTerrian);
|
||||||
|
|
||||||
|
void Request(CArea * pArea);
|
||||||
|
|
||||||
|
bool Fetch(CArea ** ppArea);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static UINT CALLBACK EntryPoint(void * pThis);
|
||||||
|
UINT Run(void * arg);
|
||||||
|
|
||||||
|
void * Arg() const { return m_pArg; }
|
||||||
|
void Arg(void * arg) { m_pArg = arg; }
|
||||||
|
|
||||||
|
HANDLE m_hThread;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void * m_pArg;
|
||||||
|
unsigned m_uThreadID;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
UINT Setup();
|
||||||
|
UINT Execute(void * pvArg);
|
||||||
|
void Destroy();
|
||||||
|
void ProcessTerrain();
|
||||||
|
void ProcessArea();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::deque<CTerrain *> m_pTerrainRequestDeque;
|
||||||
|
Mutex m_TerrainRequestMutex;
|
||||||
|
|
||||||
|
std::deque<CTerrain *> m_pTerrainCompleteDeque;
|
||||||
|
Mutex m_TerrainCompleteMutex;
|
||||||
|
|
||||||
|
std::deque<CArea *> m_pAreaRequestDeque;
|
||||||
|
Mutex m_AreaRequestMutex;
|
||||||
|
|
||||||
|
std::deque<CArea *> m_pAreaCompleteDeque;
|
||||||
|
Mutex m_AreaCompleteMutex;
|
||||||
|
|
||||||
|
HANDLE m_hSemaphore;
|
||||||
|
int m_iRestSemCount;
|
||||||
|
bool m_bShutdowned;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // !defined(AFX_AREALOADERTHREAD_H__E43FBE42_42F4_4F0E_B9DA_D7B7C5EA0753__INCLUDED_)
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
class IFlyEventHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IFlyEventHandler() {}
|
||||||
|
virtual ~IFlyEventHandler() {}
|
||||||
|
|
||||||
|
// Call by ActorInstance
|
||||||
|
virtual void OnSetFlyTarget() {}
|
||||||
|
virtual void OnShoot(DWORD dwSkillIndex) {}
|
||||||
|
|
||||||
|
virtual void OnNoTarget() {}
|
||||||
|
virtual void OnNoArrow() {}
|
||||||
|
|
||||||
|
// Call by FlyingInstance
|
||||||
|
virtual void OnExplodingOutOfRange() {}
|
||||||
|
virtual void OnExplodingAtBackground() {}
|
||||||
|
virtual void OnExplodingAtAnotherTarget(DWORD dwSkillIndex, DWORD dwVID) {}
|
||||||
|
virtual void OnExplodingAtTarget(DWORD dwSkillIndex) {}
|
||||||
|
};
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
class CFlyTarget; // PORT: MSVC makes the friend declaration below visible; ISO C++ needs this
|
||||||
|
|
||||||
|
|
||||||
|
class IFlyTargetableObject
|
||||||
|
{
|
||||||
|
friend class CFlyTarget;
|
||||||
|
public:
|
||||||
|
IFlyTargetableObject() {}
|
||||||
|
virtual ~IFlyTargetableObject() {}
|
||||||
|
|
||||||
|
virtual D3DXVECTOR3 OnGetFlyTargetPosition() = 0;
|
||||||
|
virtual void OnShootDamage() = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
inline void ClearFlyTargeter();
|
||||||
|
private:
|
||||||
|
std::set<CFlyTarget*> m_FlyTargeterSet;
|
||||||
|
inline void AddFlyTargeter(CFlyTarget* pTargeter)
|
||||||
|
{
|
||||||
|
//if (m_FlyTargeterSet.find(pTargeter)!=m_FlyTargeterSet.end())
|
||||||
|
m_FlyTargeterSet.insert(pTargeter);
|
||||||
|
}
|
||||||
|
inline void RemoveFlyTargeter(CFlyTarget* pTargeter)
|
||||||
|
{
|
||||||
|
//if (m_FlyTargeterSet.find(pTargeter)!=m_FlyTargeterSet.end())
|
||||||
|
m_FlyTargeterSet.erase(pTargeter);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class CFlyTarget // final
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum EType
|
||||||
|
{
|
||||||
|
TYPE_NONE,
|
||||||
|
TYPE_OBJECT,
|
||||||
|
TYPE_POSITION,
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
CFlyTarget();
|
||||||
|
CFlyTarget(IFlyTargetableObject * pFlyTarget);
|
||||||
|
CFlyTarget(const D3DXVECTOR3& v3FlyTargetPosition);
|
||||||
|
CFlyTarget(const CFlyTarget& rhs);
|
||||||
|
virtual ~CFlyTarget();
|
||||||
|
|
||||||
|
void Clear();
|
||||||
|
bool IsObject();
|
||||||
|
bool IsPosition();
|
||||||
|
bool IsValidTarget();
|
||||||
|
void NotifyTargetClear();
|
||||||
|
|
||||||
|
const D3DXVECTOR3 & GetFlyTargetPosition() const;
|
||||||
|
EType GetType();
|
||||||
|
|
||||||
|
IFlyTargetableObject * GetFlyTarget();
|
||||||
|
|
||||||
|
CFlyTarget & operator = (const CFlyTarget & rhs);
|
||||||
|
void GetFlyTargetData(CFlyTarget * pFlyTarget);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void __Initialize();
|
||||||
|
|
||||||
|
private:
|
||||||
|
mutable D3DXVECTOR3 m_v3FlyTargetPosition;
|
||||||
|
IFlyTargetableObject * m_pFlyTarget;
|
||||||
|
|
||||||
|
EType m_eType;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline void IFlyTargetableObject::ClearFlyTargeter()
|
||||||
|
{
|
||||||
|
std::set<CFlyTarget*>::iterator it;
|
||||||
|
for(it = m_FlyTargeterSet.begin();it!=m_FlyTargeterSet.end();++it)
|
||||||
|
{
|
||||||
|
(*it)->NotifyTargetClear();
|
||||||
|
}
|
||||||
|
m_FlyTargeterSet.clear();
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "FlyTarget.h"
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
|
||||||
|
class CFlyingInstance;
|
||||||
|
class CFlyingData;
|
||||||
|
class CMapManager;
|
||||||
|
class CActorInstance;
|
||||||
|
|
||||||
|
class CFlyingManager : public CSingleton<CFlyingManager>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum EIndexFlyType
|
||||||
|
{
|
||||||
|
INDEX_FLY_TYPE_NORMAL,
|
||||||
|
INDEX_FLY_TYPE_FIRE_CRACKER,
|
||||||
|
INDEX_FLY_TYPE_AUTO_FIRE,
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
CFlyingManager();
|
||||||
|
virtual ~CFlyingManager();
|
||||||
|
|
||||||
|
void Destroy();
|
||||||
|
|
||||||
|
void DeleteAllInstances();
|
||||||
|
|
||||||
|
bool RegisterFlyingData(const char* c_szFilename);
|
||||||
|
bool RegisterFlyingData(const char* c_szFilename, DWORD & r_dwRetCRC);
|
||||||
|
|
||||||
|
CFlyingInstance * CreateFlyingInstanceFlyTarget(const DWORD dwID, const D3DXVECTOR3 & v3StartPosition, const CFlyTarget & cr_FlyTarget, bool canAttack);
|
||||||
|
|
||||||
|
void Update();
|
||||||
|
void Render();
|
||||||
|
|
||||||
|
void SetMapManagerPtr(CMapManager * pMapManager) { m_pMapManager = pMapManager; }
|
||||||
|
CMapManager * GetMapManagerPtr() { return m_pMapManager; }
|
||||||
|
|
||||||
|
public: // Controlled by Server
|
||||||
|
bool RegisterIndexedFlyData(DWORD dwIndex, BYTE byType, const char * c_szFileName);
|
||||||
|
void CreateIndexedFly(DWORD dwIndex, CActorInstance * pStartActor, CActorInstance * pEndActor);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void __DestroyFlyingInstanceList();
|
||||||
|
void __DestroyFlyingDataMap();
|
||||||
|
|
||||||
|
typedef std::map<DWORD, CFlyingData *> TFlyingDataMap;
|
||||||
|
typedef std::list<CFlyingInstance *> TFlyingInstanceList;
|
||||||
|
|
||||||
|
typedef struct SIndexFlyData
|
||||||
|
{
|
||||||
|
BYTE byType;
|
||||||
|
DWORD dwCRC;
|
||||||
|
} TIndexFlyData;
|
||||||
|
typedef std::map<DWORD, TIndexFlyData> TIndexFlyDataMap;
|
||||||
|
|
||||||
|
TFlyingDataMap m_kMap_pkFlyData;
|
||||||
|
TFlyingInstanceList m_kLst_pkFlyInst;
|
||||||
|
TIndexFlyDataMap m_kMap_dwIndexFlyData;
|
||||||
|
|
||||||
|
CMapManager * m_pMapManager;
|
||||||
|
|
||||||
|
DWORD m_IDCounter;
|
||||||
|
};
|
||||||
@@ -0,0 +1,195 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "../EterLib/TextFileLoader.h"
|
||||||
|
#include "../EterLib/CollisionData.h"
|
||||||
|
|
||||||
|
extern float g_fGameFPS;
|
||||||
|
|
||||||
|
extern std::string g_strResourcePath;
|
||||||
|
extern std::string g_strImagePath;
|
||||||
|
|
||||||
|
// Motion Key
|
||||||
|
#define MOTION_KEY DWORD
|
||||||
|
#define MAKE_MOTION_KEY(mode, index) (((DWORD)(((BYTE)(mode)) << 24) | ((DWORD)((WORD)(index))) << 8) | ((DWORD)((BYTE)(0))))
|
||||||
|
#define MAKE_RANDOM_MOTION_KEY(mode, index, type) (((DWORD)(((BYTE)(mode)) << 24) | ((DWORD)((WORD)(index))) << 8) | ((DWORD)((BYTE)(type))))
|
||||||
|
#define GET_MOTION_MODE(key) ((BYTE)(((DWORD)(key) >> 24) & 0xFF))
|
||||||
|
#define GET_MOTION_INDEX(key) ((WORD)(((DWORD)(key) >> 8) & 0xFFFF))
|
||||||
|
#define GET_MOTION_SUB_INDEX(key) ((BYTE)(((DWORD)(key)) & 0xFF))
|
||||||
|
/*
|
||||||
|
#define MAKE_MOTION_KEY(mode, index) MAKELONG(index, mode)
|
||||||
|
#define GET_MOTION_MODE(key) HIWORD(key)
|
||||||
|
#define GET_MOTION_INDEX(key) LOWORD(key)
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Race Data
|
||||||
|
namespace NRaceData
|
||||||
|
{
|
||||||
|
enum EJobs
|
||||||
|
{
|
||||||
|
JOB_WARRIOR,
|
||||||
|
JOB_ASSASSIN,
|
||||||
|
JOB_SURA,
|
||||||
|
JOB_SHAMAN,
|
||||||
|
JOB_MAX_NUM
|
||||||
|
};
|
||||||
|
|
||||||
|
// Character Attacking Data
|
||||||
|
enum EAttackType
|
||||||
|
{
|
||||||
|
ATTACK_TYPE_SPLASH,
|
||||||
|
ATTACK_TYPE_SNIPE,
|
||||||
|
};
|
||||||
|
enum EHitType
|
||||||
|
{
|
||||||
|
HIT_TYPE_NONE,
|
||||||
|
HIT_TYPE_GREAT,
|
||||||
|
HIT_TYPE_GOOD,
|
||||||
|
};
|
||||||
|
enum EMotionType
|
||||||
|
{
|
||||||
|
MOTION_TYPE_NONE,
|
||||||
|
MOTION_TYPE_NORMAL,
|
||||||
|
MOTION_TYPE_COMBO,
|
||||||
|
MOTION_TYPE_SKILL,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef CDynamicSphereInstance THitTimePosition;
|
||||||
|
typedef std::map<float, THitTimePosition> THitTimePositionMap;
|
||||||
|
|
||||||
|
typedef struct SAttackData
|
||||||
|
{
|
||||||
|
int iAttackType;
|
||||||
|
int iHittingType;
|
||||||
|
float fInvisibleTime;
|
||||||
|
float fExternalForce;
|
||||||
|
float fStiffenTime;
|
||||||
|
int iHitLimitCount;
|
||||||
|
} TAttackData;
|
||||||
|
|
||||||
|
typedef struct SHitData
|
||||||
|
{
|
||||||
|
float fAttackStartTime;
|
||||||
|
float fAttackEndTime;
|
||||||
|
|
||||||
|
float fWeaponLength;
|
||||||
|
std::string strBoneName;
|
||||||
|
|
||||||
|
THitTimePositionMap mapHitPosition;
|
||||||
|
|
||||||
|
bool Load(CTextFileLoader & rTextFileLoader);
|
||||||
|
} THitData;
|
||||||
|
|
||||||
|
typedef std::vector<THitData> THitDataContainer;
|
||||||
|
|
||||||
|
typedef struct SMotionAttackData : public SAttackData
|
||||||
|
{
|
||||||
|
int iMotionType;
|
||||||
|
|
||||||
|
THitDataContainer HitDataContainer;
|
||||||
|
} TMotionAttackData;
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Character Attaching Collision Data
|
||||||
|
enum ECollisionType
|
||||||
|
{
|
||||||
|
COLLISION_TYPE_NONE,
|
||||||
|
|
||||||
|
COLLISION_TYPE_BODY,
|
||||||
|
COLLISION_TYPE_ATTACKING,
|
||||||
|
COLLISION_TYPE_DEFENDING,
|
||||||
|
COLLISION_TYPE_SPLASH,
|
||||||
|
};
|
||||||
|
enum ECollisionShape
|
||||||
|
{
|
||||||
|
COLLISION_SHAPE_SPHERE,
|
||||||
|
COLLISION_SHAPE_CYLINDER,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct SCollisionData
|
||||||
|
{
|
||||||
|
int iCollisionType;
|
||||||
|
CSphereCollisionInstanceVector SphereDataVector;
|
||||||
|
|
||||||
|
SCollisionData() {}
|
||||||
|
virtual ~SCollisionData() {}
|
||||||
|
} TCollisionData;
|
||||||
|
|
||||||
|
typedef struct SAttachingEffectData
|
||||||
|
{
|
||||||
|
std::string strFileName;
|
||||||
|
D3DXVECTOR3 v3Position;
|
||||||
|
D3DXVECTOR3 v3Rotation;
|
||||||
|
|
||||||
|
SAttachingEffectData() {}
|
||||||
|
virtual ~SAttachingEffectData() {}
|
||||||
|
} TAttachingEffectData;
|
||||||
|
|
||||||
|
typedef struct SAttachingObjectData
|
||||||
|
{
|
||||||
|
std::string strFileName;
|
||||||
|
|
||||||
|
SAttachingObjectData() {}
|
||||||
|
virtual ~SAttachingObjectData() {}
|
||||||
|
} TAttachingObjectData;
|
||||||
|
|
||||||
|
typedef std::vector<TCollisionData> TCollisionDataVector;
|
||||||
|
|
||||||
|
void DestroySystem();
|
||||||
|
|
||||||
|
void SaveAttackData(FILE * File, int iTabCount, const TAttackData & c_rData);
|
||||||
|
void SaveMotionAttackData(FILE * File, int iTabCount, const TMotionAttackData & c_rData);
|
||||||
|
void SaveCollisionData(FILE * File, int iTabCount, const TCollisionData & c_rCollisionData);
|
||||||
|
void SaveEffectData(FILE * File, int iTabCount, const TAttachingEffectData & c_rEffectData);
|
||||||
|
void SaveObjectData(FILE * File, int iTabCount, const TAttachingObjectData & c_rObjectData);
|
||||||
|
|
||||||
|
BOOL LoadAttackData(CTextFileLoader & rTextFileLoader, TAttackData * pData);
|
||||||
|
BOOL LoadMotionAttackData(CTextFileLoader & rTextFileLoader, TMotionAttackData * pData);
|
||||||
|
BOOL LoadCollisionData(CTextFileLoader & rTextFileLoader, TCollisionData * pCollisionData);
|
||||||
|
BOOL LoadEffectData(CTextFileLoader & rTextFileLoader, TAttachingEffectData * pEffectData);
|
||||||
|
BOOL LoadObjectData(CTextFileLoader & rTextFileLoader, TAttachingObjectData * pObjectData);
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Attaching Data
|
||||||
|
enum EAttachingDataType
|
||||||
|
{
|
||||||
|
ATTACHING_DATA_TYPE_NONE,
|
||||||
|
|
||||||
|
ATTACHING_DATA_TYPE_COLLISION_DATA,
|
||||||
|
ATTACHING_DATA_TYPE_EFFECT,
|
||||||
|
ATTACHING_DATA_TYPE_OBJECT,
|
||||||
|
|
||||||
|
ATTACHING_DATA_TYPE_MAX_NUM,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct SAttachingData
|
||||||
|
{
|
||||||
|
SAttachingData()
|
||||||
|
: dwType(0)
|
||||||
|
, isAttaching(false)
|
||||||
|
, dwAttachingModelIndex(0)
|
||||||
|
, pCollisionData(NULL)
|
||||||
|
, pEffectData(NULL)
|
||||||
|
, pObjectData(NULL)
|
||||||
|
{}
|
||||||
|
DWORD dwType;
|
||||||
|
|
||||||
|
BOOL isAttaching;
|
||||||
|
DWORD dwAttachingModelIndex;
|
||||||
|
std::string strAttachingBoneName;
|
||||||
|
|
||||||
|
TCollisionData * pCollisionData;
|
||||||
|
TAttachingEffectData * pEffectData;
|
||||||
|
TAttachingObjectData * pObjectData;
|
||||||
|
} TAttachingData;
|
||||||
|
|
||||||
|
typedef std::vector<TAttachingData> TAttachingDataVector;
|
||||||
|
|
||||||
|
void SaveAttachingData(FILE * File, int iTabCount, const TAttachingDataVector & c_rAttachingDataVector);
|
||||||
|
BOOL LoadAttachingData(CTextFileLoader & rTextFileLoader, TAttachingDataVector * pAttachingDataVector);
|
||||||
|
|
||||||
|
extern CDynamicPool<TCollisionData> g_CollisionDataPool;
|
||||||
|
extern CDynamicPool<TAttachingEffectData> g_EffectDataPool;
|
||||||
|
extern CDynamicPool<TAttachingObjectData> g_ObjectDataPool;
|
||||||
|
};
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// Collision Detection
|
||||||
|
// Dynamic VS Dynamic
|
||||||
|
bool DetectCollisionDynamicSphereVSDynamicSphere(const CDynamicSphereInstance & c_rSphere1, const CDynamicSphereInstance & c_rSphere2);
|
||||||
|
bool DetectCollisionDynamicZCylinderVSDynamicZCylinder(const CDynamicSphereInstance & c_rSphere1, const CDynamicSphereInstance & c_rSphere2);
|
||||||
|
// Dynamic VS Static
|
||||||
|
//bool DetectCollisionDynamicSphereVSStaticPlane(const CDynamicSphereInstance & c_rSphere, const TPlaneData & c_rPlaneData);
|
||||||
|
//bool DetectCollisionDynamicSphereVSStaticSphere(const CDynamicSphereInstance & c_rSphere, const TSphereData & c_rSphereData);
|
||||||
|
//bool DetectCollisionDynamicSphereVSStaticCylinder(const CDynamicSphereInstance & c_rSphere, const TCylinderData & c_rCylinderData);
|
||||||
|
//bool DetectCollisionDynamicSphereVSStaticBox(const TSphereInstance & c_rSphere, const TBoxData & c_rBoxData);
|
||||||
|
// Static VS Static
|
||||||
|
//bool DetectCollisionStaticSphereVSStaticSphere(const CDynamicSphereInstance & c_rSphere1, const TSphereData & c_rSphere2);
|
||||||
|
//bool DetectCollisionStaticSphereVSStaticCylinder(const CDynamicSphereInstance & c_rSphere, const TCylinderData & c_rCylinder);
|
||||||
|
//bool DetectCollisionStaticSphereVSStaticBox(const TSphereData & c_rSphere, const TBoxData & c_rBox);
|
||||||
|
|
||||||
|
// Rotation
|
||||||
|
float GetDegreeFromPosition(float x, float y);
|
||||||
|
float GetDegreeFromPosition2(float sx, float sy, float ex, float ey);
|
||||||
|
|
||||||
|
float GetInterpolatedRotation(float begin, float end, float curRate);
|
||||||
|
bool IsSameDirectionRotation();
|
||||||
|
bool IsCWRotation(float begin, float end);
|
||||||
|
bool IsCCWRotation(float begin, float end);
|
||||||
|
|
||||||
|
bool IsCWAcuteAngle(float begin, float end);
|
||||||
|
bool IsCCWAcuteAngle(float begin, float end);
|
||||||
|
|
||||||
|
// NOTE - Finally, this code is same with upper rotating direction code.
|
||||||
|
enum EDegree_Direction
|
||||||
|
{
|
||||||
|
DEGREE_DIRECTION_SAME = 0,
|
||||||
|
DEGREE_DIRECTION_RIGHT = 1,
|
||||||
|
DEGREE_DIRECTION_LEFT = 2,
|
||||||
|
};
|
||||||
|
float GetDegreeDifference(float fSource, float fTarget);
|
||||||
|
int GetRotatingDirection(float fSource, float fTarget);
|
||||||
|
|
||||||
|
// Converting Rotation
|
||||||
|
float CameraRotationToCharacterRotation(float fCameraRotation);
|
||||||
|
float CharacterRotationToCameraRotation(float fCharacterRotation);
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// 2004.07.05.myevan.궁신탄영 맵에 끼이는 문제해결
|
||||||
|
class IBackground : public CSingleton<IBackground>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IBackground() {}
|
||||||
|
virtual ~IBackground() {}
|
||||||
|
|
||||||
|
virtual bool IsBlock(int x, int y) = 0;
|
||||||
|
};
|
||||||
@@ -0,0 +1,222 @@
|
|||||||
|
#ifndef __MapType_Header__
|
||||||
|
#define __MapType_Header__
|
||||||
|
|
||||||
|
class CProperty;
|
||||||
|
|
||||||
|
#include "../EterLib/SkyBox.h"
|
||||||
|
#include "../MilesLib/SoundManager.h"
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////
|
||||||
|
// Property
|
||||||
|
namespace prt
|
||||||
|
{
|
||||||
|
enum EPropertyType
|
||||||
|
{
|
||||||
|
PROPERTY_TYPE_NONE,
|
||||||
|
PROPERTY_TYPE_TREE,
|
||||||
|
PROPERTY_TYPE_BUILDING,
|
||||||
|
PROPERTY_TYPE_EFFECT,
|
||||||
|
PROPERTY_TYPE_AMBIENCE,
|
||||||
|
PROPERTY_TYPE_DUNGEON_BLOCK,
|
||||||
|
PROPERTY_TYPE_MAX_NUM,
|
||||||
|
};
|
||||||
|
|
||||||
|
const char c_szPropertyTypeName[PROPERTY_TYPE_MAX_NUM][32] =
|
||||||
|
{
|
||||||
|
"None",
|
||||||
|
"Tree",
|
||||||
|
"Building",
|
||||||
|
"Effect",
|
||||||
|
"Ambience",
|
||||||
|
"DungeonBlock"
|
||||||
|
};
|
||||||
|
|
||||||
|
const char c_szPropertyExtension[PROPERTY_TYPE_MAX_NUM][16] =
|
||||||
|
{
|
||||||
|
".pr",
|
||||||
|
".prt",
|
||||||
|
".prb",
|
||||||
|
".pre",
|
||||||
|
".pra",
|
||||||
|
".prd"
|
||||||
|
};
|
||||||
|
|
||||||
|
DWORD GetPropertyType(const char * c_szTypeName);
|
||||||
|
const char * GetPropertyExtension(DWORD dwType);
|
||||||
|
|
||||||
|
struct TPropertyTree
|
||||||
|
{
|
||||||
|
std::string strName;
|
||||||
|
std::string strFileName;
|
||||||
|
|
||||||
|
float fSize;
|
||||||
|
float fVariance;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TPropertyBuilding
|
||||||
|
{
|
||||||
|
std::string strName;
|
||||||
|
std::string strFileName;
|
||||||
|
std::string strAttributeDataFileName;
|
||||||
|
BOOL isShadowFlag;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TPropertyEffect
|
||||||
|
{
|
||||||
|
std::string strName;
|
||||||
|
std::string strFileName;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum EAmbiencePlayType
|
||||||
|
{
|
||||||
|
AMBIENCE_PLAY_TYPE_ONCE,
|
||||||
|
AMBIENCE_PLAY_TYPE_STEP,
|
||||||
|
AMBIENCE_PLAY_TYPE_LOOP,
|
||||||
|
AMBIENCE_PLAY_TYPE_MAX_NUM,
|
||||||
|
};
|
||||||
|
|
||||||
|
const char c_szPlayTypeName[AMBIENCE_PLAY_TYPE_MAX_NUM][8] =
|
||||||
|
{
|
||||||
|
"ONCE",
|
||||||
|
"STEP",
|
||||||
|
"LOOP",
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TPropertyAmbience
|
||||||
|
{
|
||||||
|
std::string strName;
|
||||||
|
std::string strPlayType;
|
||||||
|
|
||||||
|
float fPlayInterval;
|
||||||
|
float fPlayIntervalVariation;
|
||||||
|
float fMaxVolumeAreaPercentage;
|
||||||
|
std::vector<std::string> AmbienceSoundVector;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TPropertyDungeonBlock
|
||||||
|
{
|
||||||
|
std::string strName;
|
||||||
|
std::string strFileName;
|
||||||
|
std::string strAttributeDataFileName;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool PropertyTreeDataToString(TPropertyTree * pData, CProperty * pProperty);
|
||||||
|
bool PropertyTreeStringToData(CProperty * pProperty, TPropertyTree * pData);
|
||||||
|
bool PropertyBuildingDataToString(TPropertyBuilding * pData, CProperty * pProperty);
|
||||||
|
bool PropertyBuildingStringToData(CProperty * pProperty, TPropertyBuilding * pData);
|
||||||
|
bool PropertyEffectDataToString(TPropertyEffect * pData, CProperty * pProperty);
|
||||||
|
bool PropertyEffectStringToData(CProperty * pProperty, TPropertyEffect * pData);
|
||||||
|
bool PropertyAmbienceDataToString(TPropertyAmbience * pData, CProperty * pProperty);
|
||||||
|
bool PropertyAmbienceStringToData(CProperty * pProperty, TPropertyAmbience * pData);
|
||||||
|
bool PropertyDungeonBlockDataToString(TPropertyDungeonBlock * pData, CProperty * pProperty);
|
||||||
|
bool PropertyDungeonBlockStringToData(CProperty * pProperty, TPropertyDungeonBlock * pData);
|
||||||
|
};
|
||||||
|
/////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////
|
||||||
|
// Environment
|
||||||
|
//
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
ENV_DIRLIGHT_BACKGROUND,
|
||||||
|
ENV_DIRLIGHT_CHARACTER,
|
||||||
|
ENV_DIRLIGHT_NUM
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct SEnvironmentData
|
||||||
|
{
|
||||||
|
// Light
|
||||||
|
BOOL bDirLightsEnable[ENV_DIRLIGHT_NUM];
|
||||||
|
D3DLIGHT8 DirLights[ENV_DIRLIGHT_NUM];
|
||||||
|
|
||||||
|
// Material
|
||||||
|
D3DMATERIAL8 Material;
|
||||||
|
|
||||||
|
// Fog
|
||||||
|
BOOL bFogEnable;
|
||||||
|
BOOL bDensityFog;
|
||||||
|
|
||||||
|
float m_fFogNearDistance;
|
||||||
|
float m_fFogFarDistance;
|
||||||
|
|
||||||
|
float GetFogNearDistance() const;
|
||||||
|
float GetFogFarDistance() const;
|
||||||
|
|
||||||
|
D3DXCOLOR FogColor;
|
||||||
|
|
||||||
|
// Filtering
|
||||||
|
BOOL bFilteringEnable;
|
||||||
|
D3DXCOLOR FilteringColor;
|
||||||
|
BYTE byFilteringAlphaSrc;
|
||||||
|
BYTE byFilteringAlphaDest;
|
||||||
|
|
||||||
|
// Wind
|
||||||
|
float fWindStrength;
|
||||||
|
float fWindRandom;
|
||||||
|
|
||||||
|
// SkyBox
|
||||||
|
D3DXVECTOR3 v3SkyBoxScale;
|
||||||
|
BOOL bSkyBoxTextureRenderMode;
|
||||||
|
|
||||||
|
BYTE bySkyBoxGradientLevelUpper;
|
||||||
|
BYTE bySkyBoxGradientLevelLower;
|
||||||
|
|
||||||
|
std::string strSkyBoxFaceFileName[6]; //order : front/back/left/right/top/bottom
|
||||||
|
|
||||||
|
|
||||||
|
D3DXVECTOR2 v2CloudScale;
|
||||||
|
float fCloudHeight;
|
||||||
|
D3DXVECTOR2 v2CloudTextureScale;
|
||||||
|
D3DXVECTOR2 v2CloudSpeed;
|
||||||
|
std::string strCloudTextureFileName;
|
||||||
|
TGradientColor CloudGradientColor;
|
||||||
|
|
||||||
|
std::vector<TGradientColor> SkyBoxGradientColorVector;
|
||||||
|
|
||||||
|
// LensFlare
|
||||||
|
BOOL bLensFlareEnable;
|
||||||
|
D3DXCOLOR LensFlareBrightnessColor;
|
||||||
|
float fLensFlareMaxBrightness;
|
||||||
|
|
||||||
|
BOOL bMainFlareEnable;
|
||||||
|
std::string strMainFlareTextureFileName;
|
||||||
|
float fMainFlareSize;
|
||||||
|
|
||||||
|
BOOL bReserve; // 외부에서 설정을 고치지 않음
|
||||||
|
} TEnvironmentData;
|
||||||
|
|
||||||
|
typedef std::map<DWORD, TEnvironmentData*> TEnvironmentDataMap;
|
||||||
|
/////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
typedef struct SScreenPosition {
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
} TScreenPosition;
|
||||||
|
|
||||||
|
typedef D3DXVECTOR3 TPixelPosition;
|
||||||
|
|
||||||
|
float SPixelPosition_CalculateDistanceSq3d(const TPixelPosition& c_rkPPosLeft, const TPixelPosition& c_rkPPosRight);
|
||||||
|
|
||||||
|
typedef struct SCellPosition
|
||||||
|
{
|
||||||
|
SCellPosition()
|
||||||
|
{
|
||||||
|
this->x = 0;
|
||||||
|
this->y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCellPosition(int x, int y)
|
||||||
|
{
|
||||||
|
this->x = x;
|
||||||
|
this->y = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
int x, y;
|
||||||
|
} TCellPosition;
|
||||||
|
|
||||||
|
const int c_Section_xAttributeCellSize = 50;
|
||||||
|
const int c_Section_yAttributeCellSize = 50;
|
||||||
|
const int c_Section_xCellSize = 100;
|
||||||
|
const int c_Section_yCellSize = 100;
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
void Environment_Init(SEnvironmentData& envData);
|
||||||
|
bool Environment_Load(SEnvironmentData& envData, const char* envFileName);
|
||||||
|
|
||||||
|
|
||||||
|
void GetInterpolatedPosition(float curPositionRate, TPixelPosition * PixelPosition);
|
||||||
|
float GetLinearInterpolation(float begin, float end, float curRate);
|
||||||
|
|
||||||
|
void PixelPositionToAttributeCellPosition(TPixelPosition PixelPosition, TCellPosition * pAttrCellPosition);
|
||||||
|
void AttributeCellPositionToPixelPosition(TCellPosition AttrCellPosition, TPixelPosition * pPixelPosition);
|
||||||
|
|
||||||
|
float GetPixelPositionDistance(const TPixelPosition & c_rsrcPosition, const TPixelPosition & c_rdstPosition);
|
||||||
|
|
||||||
|
class CEaseOutInterpolation
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CEaseOutInterpolation();
|
||||||
|
virtual ~CEaseOutInterpolation();
|
||||||
|
|
||||||
|
void Initialize();
|
||||||
|
|
||||||
|
BOOL Setup(float fStart, float fEnd, float fTime);
|
||||||
|
void Interpolate(float fElapsedTime);
|
||||||
|
BOOL isPlaying();
|
||||||
|
|
||||||
|
float GetValue();
|
||||||
|
float GetChangingValue();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
float m_fRemainingTime;
|
||||||
|
float m_fValue;
|
||||||
|
float m_fSpeed;
|
||||||
|
float m_fAcceleration;
|
||||||
|
|
||||||
|
float m_fStartValue;
|
||||||
|
float m_fLastValue;
|
||||||
|
};
|
||||||
@@ -0,0 +1,125 @@
|
|||||||
|
// MonsterAreaInfo.h: interface for the CMonsterAreaInfo class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if !defined(AFX_MONSTERAREAINFO_H__B177E257_2EB2_4CE5_89D3_D06B5618BE1B__INCLUDED_)
|
||||||
|
#define AFX_MONSTERAREAINFO_H__B177E257_2EB2_4CE5_89D3_D06B5618BE1B__INCLUDED_
|
||||||
|
|
||||||
|
#if _MSC_VER > 1000
|
||||||
|
#pragma once
|
||||||
|
#endif // _MSC_VER > 1000
|
||||||
|
|
||||||
|
class CMonsterAreaInfo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum EMonsterAreaInfoType
|
||||||
|
{
|
||||||
|
MONSTERAREAINFOTYPE_INVALID,
|
||||||
|
MONSTERAREAINFOTYPE_MONSTER,
|
||||||
|
MONSTERAREAINFOTYPE_GROUP,
|
||||||
|
};
|
||||||
|
enum EMonsterDir
|
||||||
|
{
|
||||||
|
DIR_RANDOM = 0,
|
||||||
|
DIR_NORTH,
|
||||||
|
DIR_NORTHEAST,
|
||||||
|
DIR_EAST,
|
||||||
|
DIR_SOUTHEAST,
|
||||||
|
DIR_SOUTH,
|
||||||
|
DIR_SOUTHWEST,
|
||||||
|
DIR_WEST,
|
||||||
|
DIR_NORTHWEST
|
||||||
|
};
|
||||||
|
|
||||||
|
CMonsterAreaInfo();
|
||||||
|
virtual ~CMonsterAreaInfo();
|
||||||
|
|
||||||
|
void SetID(DWORD dwID) { m_dwID = dwID; }
|
||||||
|
DWORD GetID() { return m_dwID; }
|
||||||
|
|
||||||
|
void Clear();
|
||||||
|
|
||||||
|
//
|
||||||
|
void SetOrigin(long lOriginX, long lOriginY);
|
||||||
|
void GetOrigin(long * plOriginX, long * plOriginY);
|
||||||
|
|
||||||
|
void SetSize(long lSizeX, long lSizeY);
|
||||||
|
void GetSize(long * plSizeX, long * plSizeY);
|
||||||
|
|
||||||
|
long GetLeft() { return m_lLeft; }
|
||||||
|
long GetTop() { return m_lTop; }
|
||||||
|
long GetRight() { return m_lRight; }
|
||||||
|
long GetBottom() { return m_lBottom; }
|
||||||
|
|
||||||
|
public:
|
||||||
|
void SetMonsterAreaInfoType(EMonsterAreaInfoType eMonsterAreaInfoType) { m_eMonsterAreaInfoType = eMonsterAreaInfoType; }
|
||||||
|
EMonsterAreaInfoType GetMonsterAreaInfoType() { return m_eMonsterAreaInfoType; }
|
||||||
|
|
||||||
|
public:
|
||||||
|
void SetMonsterGroupID(DWORD dwGroupID) { m_dwGroupID = dwGroupID;}
|
||||||
|
void SetMonsterGroupName(std::string strGroupName) { m_strGroupName = strGroupName; }
|
||||||
|
void SetMonsterGroupLeaderName(std::string strGroupLeaderName) { m_strLeaderName = strGroupLeaderName; }
|
||||||
|
void SetMonsterGroupFollowerCount(DWORD dwFollowerCount) { m_dwFollowerCount = dwFollowerCount; }
|
||||||
|
|
||||||
|
DWORD GetMonsterGroupID() { return m_dwGroupID; }
|
||||||
|
std::string GetMonsterGroupName() { return m_strGroupName; }
|
||||||
|
std::string GetMonsterGroupLeaderName() { return m_strLeaderName; }
|
||||||
|
DWORD GetMonsterGroupFollowerCount() { return m_dwFollowerCount; }
|
||||||
|
|
||||||
|
public:
|
||||||
|
void SetMonsterName(std::string strMonsterName) { m_strMonsterName = strMonsterName; }
|
||||||
|
void SetMonsterVID(DWORD dwVID) { m_dwVID = dwVID; }
|
||||||
|
|
||||||
|
std::string GetMonsterName() { return m_strMonsterName; }
|
||||||
|
DWORD GetMonsterVID() { return m_dwVID; }
|
||||||
|
|
||||||
|
public:
|
||||||
|
void SetMonsterCount(DWORD dwCount);
|
||||||
|
void SetMonsterDirection(EMonsterDir eMonsterDir);
|
||||||
|
void RemoveAllMonsters();
|
||||||
|
|
||||||
|
DWORD GetMonsterCount() { return m_dwMonsterCount; }
|
||||||
|
EMonsterDir GetMonsterDir() { return m_eMonsterDir; }
|
||||||
|
D3DXVECTOR2 GetMonsterDirVector() { return m_v2Monsterdirection; }
|
||||||
|
D3DXVECTOR2 GetTempMonsterPos(DWORD dwIndex);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void SetLRTB();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
EMonsterAreaInfoType m_eMonsterAreaInfoType;
|
||||||
|
|
||||||
|
// Group Type 정보
|
||||||
|
DWORD m_dwGroupID;
|
||||||
|
std::string m_strGroupName;
|
||||||
|
std::string m_strLeaderName;
|
||||||
|
DWORD m_dwFollowerCount;
|
||||||
|
|
||||||
|
// Monster Type 정보
|
||||||
|
DWORD m_dwVID;
|
||||||
|
std::string m_strMonsterName;
|
||||||
|
|
||||||
|
// 공통 정보
|
||||||
|
DWORD m_dwMonsterCount;
|
||||||
|
EMonsterDir m_eMonsterDir;
|
||||||
|
D3DXVECTOR2 m_v2Monsterdirection;
|
||||||
|
|
||||||
|
DWORD m_dwID;
|
||||||
|
|
||||||
|
long m_lOriginX;
|
||||||
|
long m_lOriginY;
|
||||||
|
long m_lSizeX;
|
||||||
|
long m_lSizeY;
|
||||||
|
|
||||||
|
long m_lLeft;
|
||||||
|
long m_lRight;
|
||||||
|
long m_lTop;
|
||||||
|
long m_lBottom;
|
||||||
|
|
||||||
|
std::vector<D3DXVECTOR2> m_TempMonsterPosVector;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::vector<CMonsterAreaInfo *> TMonsterAreaInfoPtrVector;
|
||||||
|
typedef TMonsterAreaInfoPtrVector::iterator TMonsterAreaInfoPtrVectorIterator;
|
||||||
|
|
||||||
|
#endif // !defined(AFX_MONSTERAREAINFO_H__B177E257_2EB2_4CE5_89D3_D06B5618BE1B__INCLUDED_)
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
#ifndef __INC_YMIR_GAMELIB__
|
||||||
|
#define __INC_YMIR_GAMELIB__
|
||||||
|
|
||||||
|
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||||
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#pragma warning(disable:4710) // not inlined
|
||||||
|
#pragma warning(disable:4786) // character 255 넘어가는거 끄기
|
||||||
|
#pragma warning(disable:4244) // type conversion possible lose of data
|
||||||
|
|
||||||
|
#pragma warning(disable:4018)
|
||||||
|
#pragma warning(disable:4245)
|
||||||
|
#pragma warning(disable:4512)
|
||||||
|
#pragma warning(disable:4201)
|
||||||
|
|
||||||
|
#if _MSC_VER >= 1400
|
||||||
|
#pragma warning(disable:4201 4512 4238 4239)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "../EterBase/Utils.h"
|
||||||
|
#include "../EterBase/CRC32.h"
|
||||||
|
#include "../EterBase/Random.h"
|
||||||
|
|
||||||
|
#include "../EterLib/StdAfx.h"
|
||||||
|
#include "../MilesLib/Stdafx.h"
|
||||||
|
#include "../EffectLib/StdAfx.h"
|
||||||
|
|
||||||
|
#include "GameType.h"
|
||||||
|
#include "GameUtil.h"
|
||||||
|
#include "MapType.h"
|
||||||
|
#include "MapUtil.h"
|
||||||
|
#include "Interface.h"
|
||||||
|
|
||||||
|
//#include "FlyingObjectManager.h"
|
||||||
|
//#include "FlyingData.h"
|
||||||
|
//#include "FlyingInstance.h"
|
||||||
|
|
||||||
|
|
||||||
|
// Octree
|
||||||
|
//#include "Octree.h"
|
||||||
|
|
||||||
|
// Item
|
||||||
|
//#include "ItemData.h"
|
||||||
|
//#include "ItemManager.h"
|
||||||
|
|
||||||
|
// Actor
|
||||||
|
//#include "WeaponTrace.h"
|
||||||
|
//#include "PhysicsObject.h"
|
||||||
|
//#include "RaceMotionData.h"
|
||||||
|
//#include "RaceData.h"
|
||||||
|
//#include "ActorInstance.h"
|
||||||
|
//#include "RaceManager.h"
|
||||||
|
|
||||||
|
// Property
|
||||||
|
//#include "Property.h"
|
||||||
|
//#include "PropertyManager.h"
|
||||||
|
//#include "PropertyLoader.h"
|
||||||
|
|
||||||
|
// Map
|
||||||
|
//#include "Area.h"
|
||||||
|
|
||||||
|
// Path Finder
|
||||||
|
//#include "PathFinder.h"
|
||||||
|
|
||||||
|
// Game Event Manager
|
||||||
|
//#include "GameEventManager.h"
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
#ifndef __MILESLIB_CSOUNDBASE_H__
|
||||||
|
#define __MILESLIB_CSOUNDBASE_H__
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
#include "SoundData.h"
|
||||||
|
|
||||||
|
typedef struct SProvider
|
||||||
|
{
|
||||||
|
char* name;
|
||||||
|
HPROVIDER hProvider;
|
||||||
|
} TProvider;
|
||||||
|
|
||||||
|
typedef std::map<DWORD, CSoundData*> TSoundDataMap;
|
||||||
|
|
||||||
|
class CSoundBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CSoundBase();
|
||||||
|
virtual ~CSoundBase();
|
||||||
|
|
||||||
|
void Initialize();
|
||||||
|
void Destroy();
|
||||||
|
|
||||||
|
CSoundData * AddFile(DWORD dwFileCRC, const char* filename);
|
||||||
|
DWORD GetFileCRC(const char* filename);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static int ms_iRefCount;
|
||||||
|
static HDIGDRIVER ms_DIGDriver;
|
||||||
|
static TProvider * ms_pProviderDefault;
|
||||||
|
static std::vector<TProvider> ms_ProviderVector;
|
||||||
|
static TSoundDataMap ms_dataMap;
|
||||||
|
static bool ms_bInitialized;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
#ifndef __MILESLIB_CSOUNDDATA_H__
|
||||||
|
#define __MILESLIB_CSOUNDDATA_H__
|
||||||
|
|
||||||
|
#include <mss.h>
|
||||||
|
#include "../EterBase/MappedFile.h"
|
||||||
|
|
||||||
|
class CSoundData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
FLAG_DATA_SIZE = 1,
|
||||||
|
SOUND_FILE_MAX_NUM = 5,
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
static void SetPackMode();
|
||||||
|
|
||||||
|
CSoundData();
|
||||||
|
virtual ~CSoundData();
|
||||||
|
|
||||||
|
void Assign(const char* filename);
|
||||||
|
LPVOID Get();
|
||||||
|
ULONG GetSize();
|
||||||
|
void Release();
|
||||||
|
DWORD GetAccessTime();
|
||||||
|
const char * GetFileName();
|
||||||
|
|
||||||
|
void SetPlayTime(DWORD dwPlayTime);
|
||||||
|
DWORD GetPlayTime();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool ReadFromDisk();
|
||||||
|
void Destroy();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
char m_filename[128];
|
||||||
|
int m_iRefCount;
|
||||||
|
DWORD m_dwAccessTime;
|
||||||
|
DWORD m_dwPlayTime;
|
||||||
|
ULONG m_size;
|
||||||
|
LPVOID m_data;
|
||||||
|
long m_flag;
|
||||||
|
bool m_assigned;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static U32 AILCALLBACK open_callback(char const * filename, U32 *file_handle);
|
||||||
|
static void AILCALLBACK close_callback(U32 file_handle);
|
||||||
|
static S32 AILCALLBACK seek_callback(U32 file_handle, S32 offset, U32 type);
|
||||||
|
static U32 AILCALLBACK read_callback(U32 file_handle, void *buffer, U32 bytes);
|
||||||
|
|
||||||
|
static bool isSlotIndex(DWORD dwIndex);
|
||||||
|
static int GetEmptySlotIndex();
|
||||||
|
|
||||||
|
static bool ms_isSoundFile[SOUND_FILE_MAX_NUM];
|
||||||
|
static CMappedFile ms_SoundFile[SOUND_FILE_MAX_NUM];
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
#ifndef __MILESLIB_CSOUNDINSTANCE_H__
|
||||||
|
#define __MILESLIB_CSOUNDINSTANCE_H__
|
||||||
|
|
||||||
|
#include "SoundBase.h"
|
||||||
|
|
||||||
|
class ISoundInstance : public CSoundBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ISoundInstance() {}
|
||||||
|
virtual ~ISoundInstance() {}
|
||||||
|
|
||||||
|
virtual bool Initialize() = 0;
|
||||||
|
virtual void Destroy() = 0;
|
||||||
|
virtual bool SetSound(CSoundData* pSound) = 0;
|
||||||
|
virtual void Play(int iLoopCount = 1, DWORD dwPlayCycleTimeLimit = 0) const = 0;
|
||||||
|
virtual void Pause() const = 0;
|
||||||
|
virtual void Resume() const = 0;
|
||||||
|
virtual void Stop() = 0;
|
||||||
|
virtual void GetVolume(float& rfVolume) const = 0;
|
||||||
|
virtual void SetVolume(float volume) const = 0;
|
||||||
|
virtual bool IsDone() const = 0;
|
||||||
|
virtual void SetPosition(float x, float y, float z) const = 0;
|
||||||
|
virtual void SetOrientation(float x_face, float y_face, float z_face,
|
||||||
|
float x_normal, float y_normal, float z_normal) const = 0;
|
||||||
|
virtual void SetVelocity(float x, float y, float z, float fMagnitude) const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CSoundInstance2D : public ISoundInstance
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CSoundInstance2D();
|
||||||
|
virtual ~CSoundInstance2D();
|
||||||
|
|
||||||
|
public: // from interface
|
||||||
|
bool Initialize();
|
||||||
|
void Destroy();
|
||||||
|
|
||||||
|
bool SetSound(CSoundData* pSound);
|
||||||
|
void Play(int iLoopCount = 1, DWORD dwPlayCycleTimeLimit = 0) const;
|
||||||
|
void Pause() const;
|
||||||
|
void Resume() const;
|
||||||
|
void Stop();
|
||||||
|
void GetVolume(float& rfVolume) const;
|
||||||
|
void SetVolume(float volume) const;
|
||||||
|
bool IsDone() const;
|
||||||
|
void SetPosition(float x, float y, float z) const;
|
||||||
|
void SetOrientation(float x_face, float y_face, float z_face,
|
||||||
|
float x_normal, float y_normal, float z_normal) const;
|
||||||
|
void SetVelocity(float fx, float fy, float fz, float fMagnitude) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
HSAMPLE m_sample;
|
||||||
|
CSoundData* m_pSoundData;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CSoundInstance3D : public ISoundInstance
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CSoundInstance3D();
|
||||||
|
virtual ~CSoundInstance3D();
|
||||||
|
|
||||||
|
public: // from interface
|
||||||
|
bool Initialize();
|
||||||
|
void Destroy();
|
||||||
|
|
||||||
|
bool SetSound(CSoundData * pSound);
|
||||||
|
void Play(int iLoopCount = 1, DWORD dwPlayCycleTimeLimit = 0) const;
|
||||||
|
void Pause() const;
|
||||||
|
void Resume() const;
|
||||||
|
void Stop();
|
||||||
|
void GetVolume(float& rfVolume) const;
|
||||||
|
void SetVolume(float volume) const;
|
||||||
|
bool IsDone() const;
|
||||||
|
|
||||||
|
void SetPosition(float x, float y, float z) const;
|
||||||
|
void SetOrientation(float x_face, float y_face, float z_face,
|
||||||
|
float x_normal, float y_normal, float z_normal) const;
|
||||||
|
void SetVelocity(float fx, float fy, float fz, float fMagnitude) const;
|
||||||
|
|
||||||
|
void UpdatePosition(float fElapsedTime);
|
||||||
|
|
||||||
|
private:
|
||||||
|
H3DSAMPLE m_sample;
|
||||||
|
CSoundData * m_pSoundData;
|
||||||
|
};
|
||||||
|
|
||||||
|
class CSoundInstanceStream : public ISoundInstance
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CSoundInstanceStream();
|
||||||
|
virtual ~CSoundInstanceStream();
|
||||||
|
|
||||||
|
public: // from interface
|
||||||
|
bool Initialize();
|
||||||
|
void Destroy();
|
||||||
|
|
||||||
|
void SetStream(HSTREAM stream);
|
||||||
|
bool SetSound(CSoundData* pSound);
|
||||||
|
|
||||||
|
void Play(int iLoopCount = 1, DWORD dwPlayCycleTimeLimit = 0) const;
|
||||||
|
void Pause() const;
|
||||||
|
void Resume() const;
|
||||||
|
void Stop();
|
||||||
|
void GetVolume(float& rfVolume) const;
|
||||||
|
void SetVolume(float volume) const;
|
||||||
|
bool IsDone() const;
|
||||||
|
bool IsData() const;
|
||||||
|
|
||||||
|
void SetPosition(float x, float y, float z) const;
|
||||||
|
void SetOrientation(float x_face, float y_face, float z_face,
|
||||||
|
float x_normal, float y_normal, float z_normal) const;
|
||||||
|
void SetVelocity(float fx, float fy, float fz, float fMagnitude) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
HSTREAM m_stream;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../EterBase/Singleton.h"
|
||||||
|
|
||||||
|
#include "SoundManagerStream.h"
|
||||||
|
#include "SoundManager2D.h"
|
||||||
|
#include "SoundManager3D.h"
|
||||||
|
#include "Type.h"
|
||||||
|
|
||||||
|
class CSoundManager : public CSingleton<CSoundManager>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CSoundManager();
|
||||||
|
virtual ~CSoundManager();
|
||||||
|
|
||||||
|
BOOL Create();
|
||||||
|
void Destroy();
|
||||||
|
|
||||||
|
void SetPosition(float fx, float fy, float fz);
|
||||||
|
void SetDirection(float fxDir, float fyDir, float fzDir, float fxUp, float fyUp, float fzUp);
|
||||||
|
void Update();
|
||||||
|
|
||||||
|
float GetSoundScale();
|
||||||
|
void SetSoundScale(float fScale);
|
||||||
|
void SetAmbienceSoundScale(float fScale);
|
||||||
|
void SetSoundVolume(float fVolume);
|
||||||
|
void SetSoundVolumeRatio(float fRatio);
|
||||||
|
void SetMusicVolume(float fVolume);
|
||||||
|
void SetMusicVolumeRatio(float fRatio);
|
||||||
|
void SetSoundVolumeGrade(int iGrade);
|
||||||
|
void SetMusicVolumeGrade(int iGrade);
|
||||||
|
void SaveVolume();
|
||||||
|
void RestoreVolume();
|
||||||
|
float GetSoundVolume();
|
||||||
|
float GetMusicVolume();
|
||||||
|
|
||||||
|
// Sound
|
||||||
|
void PlaySound2D(const char * c_szFileName);
|
||||||
|
void PlaySound3D(float fx, float fy, float fz, const char * c_szFileName, int iPlayCount = 1);
|
||||||
|
void StopSound3D(int iIndex);
|
||||||
|
int PlayAmbienceSound3D(float fx, float fy, float fz, const char * c_szFileName, int iPlayCount = 1);
|
||||||
|
void PlayCharacterSound3D(float fx, float fy, float fz, const char * c_szFileName, BOOL bCheckFrequency = FALSE);
|
||||||
|
void SetSoundVolume3D(int iIndex, float fVolume);
|
||||||
|
void StopAllSound3D();
|
||||||
|
|
||||||
|
// Music
|
||||||
|
void PlayMusic(const char * c_szFileName);
|
||||||
|
void FadeInMusic(const char * c_szFileName, float fVolumeSpeed = 0.016f);
|
||||||
|
void FadeOutMusic(const char * c_szFileName, float fVolumeSpeed = 0.016f);
|
||||||
|
void FadeLimitOutMusic(const char * c_szFileName, float fLimitVolume, float fVolumeSpeed = 0.016f);
|
||||||
|
void FadeOutAllMusic();
|
||||||
|
void FadeAll();
|
||||||
|
|
||||||
|
// Sound Node
|
||||||
|
void UpdateSoundData(DWORD dwcurFrame, const NSound::TSoundDataVector * c_pSoundDataVector);
|
||||||
|
void UpdateSoundData(float fx, float fy, float fz, DWORD dwcurFrame, const NSound::TSoundDataVector * c_pSoundDataVector);
|
||||||
|
void UpdateSoundInstance(float fx, float fy, float fz, DWORD dwcurFrame, const NSound::TSoundInstanceVector * c_pSoundInstanceVector, BOOL bCheckFrequency = FALSE);
|
||||||
|
void UpdateSoundInstance(DWORD dwcurFrame, const NSound::TSoundInstanceVector * c_pSoundInstanceVector);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
enum EMusicState
|
||||||
|
{
|
||||||
|
MUSIC_STATE_OFF,
|
||||||
|
MUSIC_STATE_PLAY,
|
||||||
|
MUSIC_STATE_FADE_IN,
|
||||||
|
MUSIC_STATE_FADE_OUT,
|
||||||
|
MUSIC_STATE_FADE_LIMIT_OUT,
|
||||||
|
};
|
||||||
|
typedef struct SMusicInstance
|
||||||
|
{
|
||||||
|
DWORD dwMusicFileNameCRC;
|
||||||
|
EMusicState MusicState;
|
||||||
|
float fVolume;
|
||||||
|
float fLimitVolume;
|
||||||
|
float fVolumeSpeed;
|
||||||
|
} TMusicInstance;
|
||||||
|
|
||||||
|
void PlayMusic(DWORD dwIndex, const char * c_szFileName, float fVolume, float fVolumeSpeed);
|
||||||
|
void StopMusic(DWORD dwIndex);
|
||||||
|
BOOL GetMusicIndex(const char * c_szFileName, DWORD * pdwIndex);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
float __ConvertGradeVolumeToApplyVolume(int nVolumeGrade);
|
||||||
|
float __ConvertRatioVolumeToApplyVolume(float fVolumeRatio);
|
||||||
|
void __SetMusicVolume(float fVolume);
|
||||||
|
BOOL GetSoundInstance2D(const char * c_szSoundFileName, ISoundInstance ** ppInstance);
|
||||||
|
BOOL GetSoundInstance3D(const char * c_szFileName, ISoundInstance ** ppInstance);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
BOOL m_bInitialized;
|
||||||
|
BOOL m_isSoundDisable;
|
||||||
|
|
||||||
|
float m_fxPosition;
|
||||||
|
float m_fyPosition;
|
||||||
|
float m_fzPosition;
|
||||||
|
|
||||||
|
float m_fSoundScale;
|
||||||
|
float m_fAmbienceSoundScale;
|
||||||
|
float m_fSoundVolume;
|
||||||
|
float m_fMusicVolume;
|
||||||
|
|
||||||
|
float m_fBackupMusicVolume;
|
||||||
|
float m_fBackupSoundVolume;
|
||||||
|
|
||||||
|
TMusicInstance m_MusicInstances[CSoundManagerStream::MUSIC_INSTANCE_MAX_NUM];
|
||||||
|
std::map<std::string, float> m_PlaySoundHistoryMap;
|
||||||
|
|
||||||
|
static CSoundManager2D ms_SoundManager2D;
|
||||||
|
static CSoundManager3D ms_SoundManager3D;
|
||||||
|
static CSoundManagerStream ms_SoundManagerStream;
|
||||||
|
};
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
#ifndef __MILESLIB_CSOUNDMANAGER2D_H__
|
||||||
|
#define __MILESLIB_CSOUNDMANAGER2D_H__
|
||||||
|
|
||||||
|
#include "SoundBase.h"
|
||||||
|
#include "SoundInstance.h"
|
||||||
|
|
||||||
|
class CSoundManager2D : public CSoundBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
INSTANCE_MAX_COUNT = 4
|
||||||
|
};
|
||||||
|
|
||||||
|
CSoundManager2D();
|
||||||
|
virtual ~CSoundManager2D();
|
||||||
|
|
||||||
|
bool Initialize();
|
||||||
|
void Destroy();
|
||||||
|
|
||||||
|
ISoundInstance * GetInstance(const char* filename);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
CSoundInstance2D ms_Instances[INSTANCE_MAX_COUNT];
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
#ifndef __MILESLIB_CSOUNDMANAGER3D_H__
|
||||||
|
#define __MILESLIB_CSOUNDMANAGER3D_H__
|
||||||
|
|
||||||
|
#include "SoundBase.h"
|
||||||
|
#include "SoundInstance.h"
|
||||||
|
|
||||||
|
class CSoundManager3D : public CSoundBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
INSTANCE_MAX_COUNT = 32,
|
||||||
|
MAX_PROVIDERS = 32,
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
CSoundManager3D();
|
||||||
|
virtual ~CSoundManager3D();
|
||||||
|
|
||||||
|
bool Initialize();
|
||||||
|
void Destroy();
|
||||||
|
|
||||||
|
int GetEmptyInstanceIndex();
|
||||||
|
int SetInstance(const char * c_szFileName);
|
||||||
|
ISoundInstance * GetInstance(DWORD dwIndex);
|
||||||
|
|
||||||
|
void SetListenerDirection(float fxDir, float fyDir, float fzDir, float fxUp, float fyUp, float fzUp);
|
||||||
|
void SetListenerPosition(float x, float y, float z);
|
||||||
|
void SetListenerVelocity(float fDistanceX, float fDistanceY, float fDistanceZ, float fNagnitude);
|
||||||
|
|
||||||
|
void Lock(int iIndex);
|
||||||
|
void Unlock(int iIndex);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool IsValidInstanceIndex(int iIndex);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool m_bLockingFlag[INSTANCE_MAX_COUNT];
|
||||||
|
CSoundInstance3D m_Instances[INSTANCE_MAX_COUNT];
|
||||||
|
H3DPOBJECT m_pListener;
|
||||||
|
|
||||||
|
bool m_bInit;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
#ifndef __MILESLIB_CSOUNDMANAGERSTREAM_H__
|
||||||
|
#define __MILESLIB_CSOUNDMANAGERSTREAM_H__
|
||||||
|
|
||||||
|
#include "SoundBase.h"
|
||||||
|
#include "SoundInstance.h"
|
||||||
|
|
||||||
|
class CSoundManagerStream : public CSoundBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
MUSIC_INSTANCE_MAX_NUM = 3,
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
CSoundManagerStream();
|
||||||
|
virtual ~CSoundManagerStream();
|
||||||
|
|
||||||
|
bool Initialize();
|
||||||
|
void Destroy();
|
||||||
|
|
||||||
|
bool SetInstance(DWORD dwIndex, const char* filename);
|
||||||
|
CSoundInstanceStream * GetInstance(DWORD dwIndex);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool CheckInstanceIndex(DWORD dwIndex);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
CSoundInstanceStream m_Instances[MUSIC_INSTANCE_MAX_NUM];
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
#ifndef __INC_MILESLIB_STDAFX_H__
|
||||||
|
#define __INC_MILESLIB_STDAFX_H__
|
||||||
|
|
||||||
|
#if _MSC_VER > 1000
|
||||||
|
#pragma once
|
||||||
|
#endif // _MSC_VER > 1000
|
||||||
|
|
||||||
|
#pragma warning(disable:4786)
|
||||||
|
#pragma warning(disable:4100)
|
||||||
|
|
||||||
|
#pragma warning(disable:4201)
|
||||||
|
#pragma warning(default:4201)
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
//#include <crtdbg.h>
|
||||||
|
|
||||||
|
#include "../EterBase/CRC32.h"
|
||||||
|
#include "../EterBase/Utils.h"
|
||||||
|
#include "../EterBase/Debug.h"
|
||||||
|
|
||||||
|
//{{AFX_INSERT_LOCATION}}
|
||||||
|
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||||
|
|
||||||
|
// Armadillo nanomite protection
|
||||||
|
#ifndef NANOBEGIN
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
#define NANOBEGIN __emit__ (0xEB,0x03,0xD6,0xD7,0x01)
|
||||||
|
#define NANOEND __emit__ (0xEB,0x03,0xD6,0xD7,0x00)
|
||||||
|
#else
|
||||||
|
#define NANOBEGIN __asm _emit 0xEB __asm _emit 0x03 __asm _emit 0xD6 __asm _emit 0xD7 __asm _emit 0x01
|
||||||
|
#define NANOEND __asm _emit 0xEB __asm _emit 0x03 __asm _emit 0xD6 __asm _emit 0xD7 __asm _emit 0x00
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace NSound
|
||||||
|
{
|
||||||
|
extern std::string strResult;
|
||||||
|
|
||||||
|
typedef struct SSoundData
|
||||||
|
{
|
||||||
|
float fTime;
|
||||||
|
std::string strSoundFileName;
|
||||||
|
} TSoundData;
|
||||||
|
typedef struct SSoundInstance
|
||||||
|
{
|
||||||
|
DWORD dwFrame;
|
||||||
|
std::string strSoundFileName;
|
||||||
|
} TSoundInstance;
|
||||||
|
typedef std::vector<TSoundData> TSoundDataVector;
|
||||||
|
typedef std::vector<TSoundInstance> TSoundInstanceVector;
|
||||||
|
|
||||||
|
bool LoadSoundInformationPiece(const char * c_szFileName, TSoundDataVector & rSoundDataVector, const char * c_szPathHeader = NULL);
|
||||||
|
bool SaveSoundInformationPiece(const char * c_szFileName, TSoundDataVector & rSoundDataVector);
|
||||||
|
void DataToInstance(const TSoundDataVector & c_rSoundDataVector, TSoundInstanceVector * pSoundInstanceVector);
|
||||||
|
|
||||||
|
const char * GetResultString();
|
||||||
|
void SetResultString(const char * c_pszStr);
|
||||||
|
};
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||||
|
//#define SPHERELIB_STRICT
|
||||||
|
//#include <crtdbg.h>
|
||||||
|
|
||||||
|
#include <d3d8.h>
|
||||||
|
#include <d3dx8.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "../EterBase/StdAfx.h"
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
/* Copyright (C) John W. Ratcliff, 2001.
|
||||||
|
* All rights reserved worldwide.
|
||||||
|
*
|
||||||
|
* This software is provided "as is" without express or implied
|
||||||
|
* warranties. You may freely copy and compile this source into
|
||||||
|
* applications you distribute provided that the copyright text
|
||||||
|
* below is included in the resulting source code, for example:
|
||||||
|
* "Portions Copyright (C) John W. Ratcliff, 2001"
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/** FRUSTUM.H : Represents a clipping frustum. */
|
||||||
|
/** You should replace this with your own more robust */
|
||||||
|
/** view frustum clipper. */
|
||||||
|
/** */
|
||||||
|
/** Written by John W. Ratcliff jratcliff@att.net */
|
||||||
|
/***********************************************************************/
|
||||||
|
|
||||||
|
#include "vector.h"
|
||||||
|
|
||||||
|
enum ViewState
|
||||||
|
{
|
||||||
|
VS_INSIDE, // completely inside the frustum.
|
||||||
|
VS_PARTIAL, // partially inside and partially outside the frustum.
|
||||||
|
VS_OUTSIDE // completely outside the frustum
|
||||||
|
};
|
||||||
|
|
||||||
|
class Frustum
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void BuildViewFrustum(D3DXMATRIX & mat);
|
||||||
|
void BuildViewFrustum2(D3DXMATRIX & mat, float fNear, float fFar, float fFov, float fAspect, const D3DXVECTOR3 & vCamera, const D3DXVECTOR3 & vLook);
|
||||||
|
ViewState ViewVolumeTest(const Vector3d &c_v3Center,const float c_fRadius) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_bUsingSphere;
|
||||||
|
D3DXVECTOR3 m_v3Center;
|
||||||
|
float m_fRadius;
|
||||||
|
D3DXPLANE m_plane[6];
|
||||||
|
};
|
||||||
@@ -0,0 +1,225 @@
|
|||||||
|
/* Copyright (C) John W. Ratcliff, 2001.
|
||||||
|
* All rights reserved worldwide.
|
||||||
|
*
|
||||||
|
* This software is provided "as is" without express or implied
|
||||||
|
* warranties. You may freely copy and compile this source into
|
||||||
|
* applications you distribute provided that the copyright text
|
||||||
|
* below is included in the resulting source code, for example:
|
||||||
|
* "Portions Copyright (C) John W. Ratcliff, 2001"
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
#include <vector>
|
||||||
|
//#include "stl.h"
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/** VECTOR.H : Template class to represent a 2d and 3d vector type. */
|
||||||
|
/** */
|
||||||
|
/** Written by John W. Ratcliff jratcliff@att.net */
|
||||||
|
/***********************************************************************/
|
||||||
|
|
||||||
|
class Vector3d : public D3DXVECTOR3
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Vector3d(void) { }; // null constructor, does not inialize point.
|
||||||
|
|
||||||
|
Vector3d(const Vector3d &a) // constructor copies existing vector.
|
||||||
|
{
|
||||||
|
x = a.x;
|
||||||
|
y = a.y;
|
||||||
|
z = a.z;
|
||||||
|
};
|
||||||
|
|
||||||
|
Vector3d(float a,float b,float c) // construct with initial point.
|
||||||
|
{
|
||||||
|
x = a;
|
||||||
|
y = b;
|
||||||
|
z = c;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool operator==(const Vector3d &a) const
|
||||||
|
{
|
||||||
|
if ( a.x == x && a.y == y && a.z == z ) return true;
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool operator!=(const Vector3d &a) const
|
||||||
|
{
|
||||||
|
if ( a.x != x || a.y != y || a.z != z ) return true;
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Operators
|
||||||
|
Vector3d& operator = (const Vector3d& A) // ASSIGNMENT (=)
|
||||||
|
{ x=A.x; y=A.y; z=A.z;
|
||||||
|
return(*this); };
|
||||||
|
|
||||||
|
Vector3d operator + (const Vector3d& A) const // ADDITION (+)
|
||||||
|
{ Vector3d Sum(x+A.x, y+A.y, z+A.z);
|
||||||
|
return(Sum); };
|
||||||
|
|
||||||
|
Vector3d operator - (const Vector3d& A) const // SUBTRACTION (-)
|
||||||
|
{ Vector3d Diff(x-A.x, y-A.y, z-A.z);
|
||||||
|
return(Diff); };
|
||||||
|
|
||||||
|
Vector3d operator * (const float s) const // MULTIPLY BY SCALAR (*)
|
||||||
|
{ Vector3d Scaled(x*s, y*s, z*s);
|
||||||
|
return(Scaled); };
|
||||||
|
|
||||||
|
Vector3d operator / (const float s) const // DIVIDE BY SCALAR (/)
|
||||||
|
{
|
||||||
|
float r = 1.0f / s;
|
||||||
|
Vector3d Scaled(x*r, y*r, z*r);
|
||||||
|
return(Scaled);
|
||||||
|
};
|
||||||
|
|
||||||
|
void operator += (const Vector3d A) // ACCUMULATED VECTOR ADDITION (+=)
|
||||||
|
{ x+=A.x; y+=A.y; z+=A.z; };
|
||||||
|
void operator -= (const Vector3d A) // ACCUMULATED VECTOR SUBTRACTION (+=)
|
||||||
|
{ x-=A.x; y-=A.y; z-=A.z; };
|
||||||
|
void operator *= (const float s) // ACCUMULATED SCALAR MULTIPLICATION (*=) (bpc 4/24/2000)
|
||||||
|
{x*=s; y*=s; z*=s;}
|
||||||
|
|
||||||
|
Vector3d operator - (void) const // NEGATION (-)
|
||||||
|
{ Vector3d Negated(-x, -y, -z);
|
||||||
|
return(Negated); };
|
||||||
|
|
||||||
|
float operator [] (const int i) const // ALLOWS VECTOR ACCESS AS AN ARRAY.
|
||||||
|
{ return( (i==0)?x:((i==1)?y:z) ); };
|
||||||
|
float & operator [] (const int i)
|
||||||
|
{ return( (i==0)?x:((i==1)?y:z) ); };
|
||||||
|
//
|
||||||
|
|
||||||
|
// accessor methods.
|
||||||
|
float GetX(void) const { return x; };
|
||||||
|
float GetY(void) const { return y; };
|
||||||
|
float GetZ(void) const { return z; };
|
||||||
|
|
||||||
|
void SetX(float t) { x = t; };
|
||||||
|
void SetY(float t) { y = t; };
|
||||||
|
void SetZ(float t) { z = t; };
|
||||||
|
|
||||||
|
void Set(float a,float b,float c)
|
||||||
|
{
|
||||||
|
x = a;
|
||||||
|
y = b;
|
||||||
|
z = c;
|
||||||
|
};
|
||||||
|
|
||||||
|
void Zero(void)
|
||||||
|
{
|
||||||
|
x = y = z = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
// return -(*this).
|
||||||
|
Vector3d negative(void) const
|
||||||
|
{
|
||||||
|
Vector3d result;
|
||||||
|
result.x = -x;
|
||||||
|
result.y = -y;
|
||||||
|
result.z = -z;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Magnitude(void) const
|
||||||
|
{
|
||||||
|
return (sqrtf(x * x + y * y + z * z));
|
||||||
|
};
|
||||||
|
|
||||||
|
void Lerp(const Vector3d& from,const Vector3d& to,float slerp)
|
||||||
|
{
|
||||||
|
*this = to-from; // delta on all 3 axis
|
||||||
|
*this*=slerp; // times interpolant distance.
|
||||||
|
*this+=from; // plus source
|
||||||
|
};
|
||||||
|
|
||||||
|
float Length(void) const // length of vector.
|
||||||
|
{
|
||||||
|
return float(sqrtf( x*x + y*y + z*z ));
|
||||||
|
};
|
||||||
|
|
||||||
|
float Length2(void) const // squared distance, prior to square root.
|
||||||
|
{
|
||||||
|
float l2 = x*x+y*y+z*z;
|
||||||
|
return l2;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline float Distance(const Vector3d &a) const // distance between two points.
|
||||||
|
{
|
||||||
|
return sqrtf(DistanceSq(a));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float Distance2d(const Vector3d &a) const // distance between two points.
|
||||||
|
{
|
||||||
|
return sqrtf(DistanceSq2d(a));
|
||||||
|
}
|
||||||
|
|
||||||
|
float DistanceXY(const Vector3d &a) const
|
||||||
|
{
|
||||||
|
float dx = a.x - x;
|
||||||
|
float dy = a.y - y;
|
||||||
|
float dist = dx*dx + dy*dy;
|
||||||
|
return dist;
|
||||||
|
}
|
||||||
|
|
||||||
|
float DistanceSq(const Vector3d &a) const // squared distance.
|
||||||
|
{
|
||||||
|
float dx = a.x - x;
|
||||||
|
float dy = a.y - y;
|
||||||
|
float dz = a.z - z;
|
||||||
|
return dx*dx + dy*dy + dz*dz;
|
||||||
|
};
|
||||||
|
|
||||||
|
float DistanceSq2d(const Vector3d &a) const // squared distance.
|
||||||
|
{
|
||||||
|
float dx = a.x - x;
|
||||||
|
float dy = a.y - y;
|
||||||
|
return dx*dx + dy*dy;
|
||||||
|
};
|
||||||
|
|
||||||
|
float Normalize(void) // normalize to a unit vector, returns distance.
|
||||||
|
{
|
||||||
|
float l = Length(); // get length.
|
||||||
|
if ( l != 0 )
|
||||||
|
{
|
||||||
|
x/=l;
|
||||||
|
y/=l;
|
||||||
|
z/=l;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x = y = z = 0;
|
||||||
|
}
|
||||||
|
return l;
|
||||||
|
};
|
||||||
|
|
||||||
|
float Dot(const Vector3d &a) const // computes dot product.
|
||||||
|
{
|
||||||
|
return (x * a.x + y * a.y + z * a.z );
|
||||||
|
};
|
||||||
|
bool IsInStaticRange() const;
|
||||||
|
void Cross(const Vector3d &a,const Vector3d &b) // cross two vectors result in this one.
|
||||||
|
{
|
||||||
|
x = a.y*b.z - a.z*b.y;
|
||||||
|
y = a.z*b.x - a.x*b.z;
|
||||||
|
z = a.x*b.y - a.y*b.x;
|
||||||
|
};
|
||||||
|
|
||||||
|
//private:
|
||||||
|
|
||||||
|
// float x;
|
||||||
|
// float y;
|
||||||
|
// float z;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
typedef std::vector< Vector3d > Vector3dVector;
|
||||||
|
|
||||||
|
inline Vector3d operator * (float s, const Vector3d &v )
|
||||||
|
{ Vector3d Scaled(v.x*s, v.y*s, v.z*s);
|
||||||
|
return(Scaled); };
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,315 @@
|
|||||||
|
#pragma once
|
||||||
|
// The Direct3D 8 value types (d3d8types.h, d3d8caps.h) that 40250 headers name: enums with the
|
||||||
|
// SDK's values, structs with the SDK's layout, and the COM interfaces as opaque types. Nothing
|
||||||
|
// here renders; platform/ implements the 40250 classes that own devices and resources.
|
||||||
|
// Added on demand as copied headers need them.
|
||||||
|
|
||||||
|
#include "Win32Types.h"
|
||||||
|
|
||||||
|
#ifndef MAKEFOURCC
|
||||||
|
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
|
||||||
|
((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef DWORD D3DCOLOR;
|
||||||
|
|
||||||
|
typedef struct _D3DVECTOR
|
||||||
|
{
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
float z;
|
||||||
|
} D3DVECTOR;
|
||||||
|
|
||||||
|
typedef struct _D3DCOLORVALUE
|
||||||
|
{
|
||||||
|
float r;
|
||||||
|
float g;
|
||||||
|
float b;
|
||||||
|
float a;
|
||||||
|
} D3DCOLORVALUE;
|
||||||
|
|
||||||
|
typedef struct _D3DMATRIX
|
||||||
|
{
|
||||||
|
union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
float _11, _12, _13, _14;
|
||||||
|
float _21, _22, _23, _24;
|
||||||
|
float _31, _32, _33, _34;
|
||||||
|
float _41, _42, _43, _44;
|
||||||
|
};
|
||||||
|
float m[4][4];
|
||||||
|
};
|
||||||
|
} D3DMATRIX;
|
||||||
|
|
||||||
|
typedef enum _D3DFORMAT
|
||||||
|
{
|
||||||
|
D3DFMT_UNKNOWN = 0,
|
||||||
|
|
||||||
|
D3DFMT_R8G8B8 = 20,
|
||||||
|
D3DFMT_A8R8G8B8 = 21,
|
||||||
|
D3DFMT_X8R8G8B8 = 22,
|
||||||
|
D3DFMT_R5G6B5 = 23,
|
||||||
|
D3DFMT_X1R5G5B5 = 24,
|
||||||
|
D3DFMT_A1R5G5B5 = 25,
|
||||||
|
D3DFMT_A4R4G4B4 = 26,
|
||||||
|
D3DFMT_R3G3B2 = 27,
|
||||||
|
D3DFMT_A8 = 28,
|
||||||
|
D3DFMT_A8R3G3B2 = 29,
|
||||||
|
D3DFMT_X4R4G4B4 = 30,
|
||||||
|
D3DFMT_A2B10G10R10 = 31,
|
||||||
|
D3DFMT_G16R16 = 34,
|
||||||
|
|
||||||
|
D3DFMT_A8P8 = 40,
|
||||||
|
D3DFMT_P8 = 41,
|
||||||
|
|
||||||
|
D3DFMT_L8 = 50,
|
||||||
|
D3DFMT_A8L8 = 51,
|
||||||
|
D3DFMT_A4L4 = 52,
|
||||||
|
|
||||||
|
D3DFMT_V8U8 = 60,
|
||||||
|
D3DFMT_L6V5U5 = 61,
|
||||||
|
D3DFMT_X8L8V8U8 = 62,
|
||||||
|
D3DFMT_Q8W8V8U8 = 63,
|
||||||
|
D3DFMT_V16U16 = 64,
|
||||||
|
D3DFMT_W11V11U10 = 65,
|
||||||
|
D3DFMT_A2W10V10U10 = 67,
|
||||||
|
|
||||||
|
D3DFMT_UYVY = MAKEFOURCC('U', 'Y', 'V', 'Y'),
|
||||||
|
D3DFMT_YUY2 = MAKEFOURCC('Y', 'U', 'Y', '2'),
|
||||||
|
D3DFMT_DXT1 = MAKEFOURCC('D', 'X', 'T', '1'),
|
||||||
|
D3DFMT_DXT2 = MAKEFOURCC('D', 'X', 'T', '2'),
|
||||||
|
D3DFMT_DXT3 = MAKEFOURCC('D', 'X', 'T', '3'),
|
||||||
|
D3DFMT_DXT4 = MAKEFOURCC('D', 'X', 'T', '4'),
|
||||||
|
D3DFMT_DXT5 = MAKEFOURCC('D', 'X', 'T', '5'),
|
||||||
|
|
||||||
|
D3DFMT_D16_LOCKABLE = 70,
|
||||||
|
D3DFMT_D32 = 71,
|
||||||
|
D3DFMT_D15S1 = 73,
|
||||||
|
D3DFMT_D24S8 = 75,
|
||||||
|
D3DFMT_D16 = 80,
|
||||||
|
D3DFMT_D24X8 = 77,
|
||||||
|
D3DFMT_D24X4S4 = 79,
|
||||||
|
|
||||||
|
D3DFMT_VERTEXDATA = 100,
|
||||||
|
D3DFMT_INDEX16 = 101,
|
||||||
|
D3DFMT_INDEX32 = 102,
|
||||||
|
|
||||||
|
D3DFMT_FORCE_DWORD = 0x7fffffff
|
||||||
|
} D3DFORMAT;
|
||||||
|
|
||||||
|
typedef enum _D3DDEVTYPE
|
||||||
|
{
|
||||||
|
D3DDEVTYPE_HAL = 1,
|
||||||
|
D3DDEVTYPE_REF = 2,
|
||||||
|
D3DDEVTYPE_SW = 3,
|
||||||
|
D3DDEVTYPE_FORCE_DWORD = 0x7fffffff
|
||||||
|
} D3DDEVTYPE;
|
||||||
|
|
||||||
|
typedef enum _D3DMULTISAMPLE_TYPE
|
||||||
|
{
|
||||||
|
D3DMULTISAMPLE_NONE = 0,
|
||||||
|
D3DMULTISAMPLE_2_SAMPLES = 2,
|
||||||
|
D3DMULTISAMPLE_3_SAMPLES = 3,
|
||||||
|
D3DMULTISAMPLE_4_SAMPLES = 4,
|
||||||
|
D3DMULTISAMPLE_5_SAMPLES = 5,
|
||||||
|
D3DMULTISAMPLE_6_SAMPLES = 6,
|
||||||
|
D3DMULTISAMPLE_7_SAMPLES = 7,
|
||||||
|
D3DMULTISAMPLE_8_SAMPLES = 8,
|
||||||
|
D3DMULTISAMPLE_9_SAMPLES = 9,
|
||||||
|
D3DMULTISAMPLE_10_SAMPLES = 10,
|
||||||
|
D3DMULTISAMPLE_11_SAMPLES = 11,
|
||||||
|
D3DMULTISAMPLE_12_SAMPLES = 12,
|
||||||
|
D3DMULTISAMPLE_13_SAMPLES = 13,
|
||||||
|
D3DMULTISAMPLE_14_SAMPLES = 14,
|
||||||
|
D3DMULTISAMPLE_15_SAMPLES = 15,
|
||||||
|
D3DMULTISAMPLE_16_SAMPLES = 16,
|
||||||
|
D3DMULTISAMPLE_FORCE_DWORD = 0x7fffffff
|
||||||
|
} D3DMULTISAMPLE_TYPE;
|
||||||
|
|
||||||
|
typedef enum _D3DFILLMODE
|
||||||
|
{
|
||||||
|
D3DFILL_POINT = 1,
|
||||||
|
D3DFILL_WIREFRAME = 2,
|
||||||
|
D3DFILL_SOLID = 3,
|
||||||
|
D3DFILL_FORCE_DWORD = 0x7fffffff
|
||||||
|
} D3DFILLMODE;
|
||||||
|
|
||||||
|
typedef enum _D3DPOOL
|
||||||
|
{
|
||||||
|
D3DPOOL_DEFAULT = 0,
|
||||||
|
D3DPOOL_MANAGED = 1,
|
||||||
|
D3DPOOL_SYSTEMMEM = 2,
|
||||||
|
D3DPOOL_SCRATCH = 3,
|
||||||
|
D3DPOOL_FORCE_DWORD = 0x7fffffff
|
||||||
|
} D3DPOOL;
|
||||||
|
|
||||||
|
typedef enum _D3DSWAPEFFECT
|
||||||
|
{
|
||||||
|
D3DSWAPEFFECT_DISCARD = 1,
|
||||||
|
D3DSWAPEFFECT_FLIP = 2,
|
||||||
|
D3DSWAPEFFECT_COPY = 3,
|
||||||
|
D3DSWAPEFFECT_COPY_VSYNC = 4,
|
||||||
|
D3DSWAPEFFECT_FORCE_DWORD = 0x7fffffff
|
||||||
|
} D3DSWAPEFFECT;
|
||||||
|
|
||||||
|
typedef enum _D3DLIGHTTYPE
|
||||||
|
{
|
||||||
|
D3DLIGHT_POINT = 1,
|
||||||
|
D3DLIGHT_SPOT = 2,
|
||||||
|
D3DLIGHT_DIRECTIONAL = 3,
|
||||||
|
D3DLIGHT_FORCE_DWORD = 0x7fffffff
|
||||||
|
} D3DLIGHTTYPE;
|
||||||
|
|
||||||
|
typedef struct _D3DDISPLAYMODE
|
||||||
|
{
|
||||||
|
UINT Width;
|
||||||
|
UINT Height;
|
||||||
|
UINT RefreshRate;
|
||||||
|
D3DFORMAT Format;
|
||||||
|
} D3DDISPLAYMODE;
|
||||||
|
|
||||||
|
#define MAX_DEVICE_IDENTIFIER_STRING 512
|
||||||
|
typedef struct _D3DADAPTER_IDENTIFIER8
|
||||||
|
{
|
||||||
|
char Driver[MAX_DEVICE_IDENTIFIER_STRING];
|
||||||
|
char Description[MAX_DEVICE_IDENTIFIER_STRING];
|
||||||
|
LARGE_INTEGER DriverVersion;
|
||||||
|
DWORD VendorId;
|
||||||
|
DWORD DeviceId;
|
||||||
|
DWORD SubSysId;
|
||||||
|
DWORD Revision;
|
||||||
|
GUID DeviceIdentifier;
|
||||||
|
DWORD WHQLLevel;
|
||||||
|
} D3DADAPTER_IDENTIFIER8;
|
||||||
|
|
||||||
|
typedef struct _D3DPRESENT_PARAMETERS_
|
||||||
|
{
|
||||||
|
UINT BackBufferWidth;
|
||||||
|
UINT BackBufferHeight;
|
||||||
|
D3DFORMAT BackBufferFormat;
|
||||||
|
UINT BackBufferCount;
|
||||||
|
D3DMULTISAMPLE_TYPE MultiSampleType;
|
||||||
|
D3DSWAPEFFECT SwapEffect;
|
||||||
|
HWND hDeviceWindow;
|
||||||
|
BOOL Windowed;
|
||||||
|
BOOL EnableAutoDepthStencil;
|
||||||
|
D3DFORMAT AutoDepthStencilFormat;
|
||||||
|
DWORD Flags;
|
||||||
|
UINT FullScreen_RefreshRateInHz;
|
||||||
|
UINT FullScreen_PresentationInterval;
|
||||||
|
} D3DPRESENT_PARAMETERS;
|
||||||
|
|
||||||
|
typedef struct _D3DVIEWPORT8
|
||||||
|
{
|
||||||
|
DWORD X;
|
||||||
|
DWORD Y;
|
||||||
|
DWORD Width;
|
||||||
|
DWORD Height;
|
||||||
|
float MinZ;
|
||||||
|
float MaxZ;
|
||||||
|
} D3DVIEWPORT8;
|
||||||
|
|
||||||
|
typedef struct _D3DMATERIAL8
|
||||||
|
{
|
||||||
|
D3DCOLORVALUE Diffuse;
|
||||||
|
D3DCOLORVALUE Ambient;
|
||||||
|
D3DCOLORVALUE Specular;
|
||||||
|
D3DCOLORVALUE Emissive;
|
||||||
|
float Power;
|
||||||
|
} D3DMATERIAL8;
|
||||||
|
|
||||||
|
typedef struct _D3DLIGHT8
|
||||||
|
{
|
||||||
|
D3DLIGHTTYPE Type;
|
||||||
|
D3DCOLORVALUE Diffuse;
|
||||||
|
D3DCOLORVALUE Specular;
|
||||||
|
D3DCOLORVALUE Ambient;
|
||||||
|
D3DVECTOR Position;
|
||||||
|
D3DVECTOR Direction;
|
||||||
|
float Range;
|
||||||
|
float Falloff;
|
||||||
|
float Attenuation0;
|
||||||
|
float Attenuation1;
|
||||||
|
float Attenuation2;
|
||||||
|
float Theta;
|
||||||
|
float Phi;
|
||||||
|
} D3DLIGHT8;
|
||||||
|
|
||||||
|
typedef struct _D3DCAPS8
|
||||||
|
{
|
||||||
|
D3DDEVTYPE DeviceType;
|
||||||
|
UINT AdapterOrdinal;
|
||||||
|
DWORD Caps;
|
||||||
|
DWORD Caps2;
|
||||||
|
DWORD Caps3;
|
||||||
|
DWORD PresentationIntervals;
|
||||||
|
DWORD CursorCaps;
|
||||||
|
DWORD DevCaps;
|
||||||
|
DWORD PrimitiveMiscCaps;
|
||||||
|
DWORD RasterCaps;
|
||||||
|
DWORD ZCmpCaps;
|
||||||
|
DWORD SrcBlendCaps;
|
||||||
|
DWORD DestBlendCaps;
|
||||||
|
DWORD AlphaCmpCaps;
|
||||||
|
DWORD ShadeCaps;
|
||||||
|
DWORD TextureCaps;
|
||||||
|
DWORD TextureFilterCaps;
|
||||||
|
DWORD CubeTextureFilterCaps;
|
||||||
|
DWORD VolumeTextureFilterCaps;
|
||||||
|
DWORD TextureAddressCaps;
|
||||||
|
DWORD VolumeTextureAddressCaps;
|
||||||
|
DWORD LineCaps;
|
||||||
|
DWORD MaxTextureWidth, MaxTextureHeight;
|
||||||
|
DWORD MaxVolumeExtent;
|
||||||
|
DWORD MaxTextureRepeat;
|
||||||
|
DWORD MaxTextureAspectRatio;
|
||||||
|
DWORD MaxAnisotropy;
|
||||||
|
float MaxVertexW;
|
||||||
|
float GuardBandLeft;
|
||||||
|
float GuardBandTop;
|
||||||
|
float GuardBandRight;
|
||||||
|
float GuardBandBottom;
|
||||||
|
float ExtentsAdjust;
|
||||||
|
DWORD StencilCaps;
|
||||||
|
DWORD FVFCaps;
|
||||||
|
DWORD TextureOpCaps;
|
||||||
|
DWORD MaxTextureBlendStages;
|
||||||
|
DWORD MaxSimultaneousTextures;
|
||||||
|
DWORD VertexProcessingCaps;
|
||||||
|
DWORD MaxActiveLights;
|
||||||
|
DWORD MaxUserClipPlanes;
|
||||||
|
DWORD MaxVertexBlendMatrices;
|
||||||
|
DWORD MaxVertexBlendMatrixIndex;
|
||||||
|
float MaxPointSize;
|
||||||
|
DWORD MaxPrimitiveCount;
|
||||||
|
DWORD MaxVertexIndex;
|
||||||
|
DWORD MaxStreams;
|
||||||
|
DWORD MaxStreamStride;
|
||||||
|
DWORD VertexShaderVersion;
|
||||||
|
DWORD MaxVertexShaderConst;
|
||||||
|
DWORD PixelShaderVersion;
|
||||||
|
float MaxPixelShaderValue;
|
||||||
|
} D3DCAPS8;
|
||||||
|
|
||||||
|
// COM interfaces: opaque here; platform/ owns every instance.
|
||||||
|
struct IDirect3D8;
|
||||||
|
struct IDirect3DDevice8;
|
||||||
|
struct IDirect3DBaseTexture8;
|
||||||
|
struct IDirect3DTexture8;
|
||||||
|
struct IDirect3DSurface8;
|
||||||
|
struct IDirect3DVertexBuffer8;
|
||||||
|
struct IDirect3DIndexBuffer8;
|
||||||
|
typedef IDirect3D8* LPDIRECT3D8;
|
||||||
|
typedef IDirect3DDevice8* LPDIRECT3DDEVICE8;
|
||||||
|
typedef IDirect3DBaseTexture8* LPDIRECT3DBASETEXTURE8;
|
||||||
|
typedef IDirect3DTexture8* LPDIRECT3DTEXTURE8;
|
||||||
|
typedef IDirect3DSurface8* LPDIRECT3DSURFACE8;
|
||||||
|
typedef IDirect3DVertexBuffer8* LPDIRECT3DVERTEXBUFFER8;
|
||||||
|
typedef IDirect3DIndexBuffer8* LPDIRECT3DINDEXBUFFER8;
|
||||||
|
|
||||||
|
static_assert(sizeof(D3DVECTOR) == 12 && sizeof(D3DCOLORVALUE) == 16 && sizeof(D3DMATRIX) == 64, "D3D8 base layout");
|
||||||
|
static_assert(sizeof(D3DDISPLAYMODE) == 16 && sizeof(D3DVIEWPORT8) == 24, "D3D8 layout");
|
||||||
|
static_assert(sizeof(D3DMATERIAL8) == 68 && sizeof(D3DLIGHT8) == 104, "D3D8 layout");
|
||||||
|
static_assert(sizeof(D3DCAPS8) == 212 && sizeof(D3DADAPTER_IDENTIFIER8) == 1072, "D3D8 caps/identifier layout");
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
// D3DX* functions follow the documented D3DX conventions (row vectors, left-handed rotations).
|
// D3DX* functions follow the documented D3DX conventions (row vectors, left-handed rotations).
|
||||||
// Functions are added on demand as ported units call them.
|
// Functions are added on demand as ported units call them.
|
||||||
|
|
||||||
#include "Win32Types.h"
|
#include "D3D8Types.h"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
@@ -14,37 +14,6 @@
|
|||||||
#define D3DXToRadian(degree) ((degree) * (D3DX_PI / 180.0f))
|
#define D3DXToRadian(degree) ((degree) * (D3DX_PI / 180.0f))
|
||||||
#define D3DXToDegree(radian) ((radian) * (180.0f / D3DX_PI))
|
#define D3DXToDegree(radian) ((radian) * (180.0f / D3DX_PI))
|
||||||
|
|
||||||
typedef DWORD D3DCOLOR;
|
|
||||||
|
|
||||||
typedef struct _D3DVECTOR
|
|
||||||
{
|
|
||||||
float x;
|
|
||||||
float y;
|
|
||||||
float z;
|
|
||||||
} D3DVECTOR;
|
|
||||||
|
|
||||||
typedef struct _D3DCOLORVALUE
|
|
||||||
{
|
|
||||||
float r;
|
|
||||||
float g;
|
|
||||||
float b;
|
|
||||||
float a;
|
|
||||||
} D3DCOLORVALUE;
|
|
||||||
|
|
||||||
typedef struct _D3DMATRIX
|
|
||||||
{
|
|
||||||
union
|
|
||||||
{
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
float _11, _12, _13, _14;
|
|
||||||
float _21, _22, _23, _24;
|
|
||||||
float _31, _32, _33, _34;
|
|
||||||
float _41, _42, _43, _44;
|
|
||||||
};
|
|
||||||
float m[4][4];
|
|
||||||
};
|
|
||||||
} D3DMATRIX;
|
|
||||||
|
|
||||||
struct D3DXVECTOR2
|
struct D3DXVECTOR2
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,8 +4,23 @@
|
|||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <mutex>
|
||||||
|
#include <new>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
static_assert(sizeof(std::recursive_mutex) <= sizeof(CRITICAL_SECTION::storage), "CRITICAL_SECTION storage");
|
||||||
|
static_assert(alignof(std::recursive_mutex) <= 16, "CRITICAL_SECTION alignment");
|
||||||
|
|
||||||
|
static std::recursive_mutex& cs_mutex(LPCRITICAL_SECTION cs)
|
||||||
|
{
|
||||||
|
return *std::launder(reinterpret_cast<std::recursive_mutex*>(cs->storage));
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitializeCriticalSection(LPCRITICAL_SECTION cs) { new (cs->storage) std::recursive_mutex(); }
|
||||||
|
void DeleteCriticalSection(LPCRITICAL_SECTION cs) { cs_mutex(cs).~recursive_mutex(); }
|
||||||
|
void EnterCriticalSection(LPCRITICAL_SECTION cs) { cs_mutex(cs).lock(); }
|
||||||
|
void LeaveCriticalSection(LPCRITICAL_SECTION cs) { cs_mutex(cs).unlock(); }
|
||||||
|
|
||||||
char* _strlwr(char* s)
|
char* _strlwr(char* s)
|
||||||
{
|
{
|
||||||
for (char* p = s; *p; ++p)
|
for (char* p = s; *p; ++p)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "Win32Types.h"
|
#include "Win32Types.h"
|
||||||
|
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
@@ -21,9 +22,15 @@ inline int stricmp(const char* a, const char* b) { return strcasecmp(a, b); }
|
|||||||
inline int _strnicmp(const char* a, const char* b, size_t n) { return strncasecmp(a, b, n); }
|
inline int _strnicmp(const char* a, const char* b, size_t n) { return strncasecmp(a, b, n); }
|
||||||
inline int strnicmp(const char* a, const char* b, size_t n) { return strncasecmp(a, b, n); }
|
inline int strnicmp(const char* a, const char* b, size_t n) { return strncasecmp(a, b, n); }
|
||||||
|
|
||||||
|
inline int _strcmpi(const char* a, const char* b) { return strcasecmp(a, b); }
|
||||||
|
|
||||||
char* _strlwr(char* s);
|
char* _strlwr(char* s);
|
||||||
char* _strupr(char* s);
|
char* _strupr(char* s);
|
||||||
|
|
||||||
|
// EterBase/StdAfx.h maps `atoi` to `_atoi64` (and `fileno` to `_fileno`) for MSVC >= 1400.
|
||||||
|
inline INT64 _atoi64(const char* s) { return std::strtoll(s, nullptr, 10); }
|
||||||
|
#define _fileno fileno
|
||||||
|
|
||||||
// MSVC `_snprintf`/`_vsnprintf`: when the output is longer than `count`, `count` bytes are written
|
// MSVC `_snprintf`/`_vsnprintf`: when the output is longer than `count`, `count` bytes are written
|
||||||
// with no terminator and -1 is returned; exactly `count` bytes are written unterminated and
|
// with no terminator and -1 is returned; exactly `count` bytes are written unterminated and
|
||||||
// `count` is returned; otherwise the output is terminated and its length returned.
|
// `count` is returned; otherwise the output is terminated and its length returned.
|
||||||
@@ -38,4 +45,15 @@ int _snprintf(char* buf, size_t count, const char* fmt, ...)
|
|||||||
DWORD timeGetTime();
|
DWORD timeGetTime();
|
||||||
DWORD GetTickCount();
|
DWORD GetTickCount();
|
||||||
|
|
||||||
|
// Recursive, like the Win32 critical section. Storage holds a std::recursive_mutex.
|
||||||
|
struct CRITICAL_SECTION
|
||||||
|
{
|
||||||
|
alignas(16) unsigned char storage[128];
|
||||||
|
};
|
||||||
|
typedef CRITICAL_SECTION* LPCRITICAL_SECTION;
|
||||||
|
void InitializeCriticalSection(LPCRITICAL_SECTION cs);
|
||||||
|
void DeleteCriticalSection(LPCRITICAL_SECTION cs);
|
||||||
|
void EnterCriticalSection(LPCRITICAL_SECTION cs);
|
||||||
|
void LeaveCriticalSection(LPCRITICAL_SECTION cs);
|
||||||
|
|
||||||
#endif // !_WIN32
|
#endif // !_WIN32
|
||||||
|
|||||||
@@ -44,6 +44,9 @@ typedef const void* LPCVOID;
|
|||||||
typedef void* PVOID;
|
typedef void* PVOID;
|
||||||
typedef char* LPSTR;
|
typedef char* LPSTR;
|
||||||
typedef const char* LPCSTR;
|
typedef const char* LPCSTR;
|
||||||
|
typedef char* PSTR;
|
||||||
|
typedef const char* PCSTR;
|
||||||
|
typedef CHAR* PCHAR;
|
||||||
typedef BYTE* LPBYTE;
|
typedef BYTE* LPBYTE;
|
||||||
typedef BYTE* PBYTE;
|
typedef BYTE* PBYTE;
|
||||||
typedef WORD* LPWORD;
|
typedef WORD* LPWORD;
|
||||||
@@ -62,6 +65,15 @@ typedef uintptr_t WPARAM;
|
|||||||
typedef intptr_t LPARAM;
|
typedef intptr_t LPARAM;
|
||||||
typedef intptr_t LRESULT;
|
typedef intptr_t LRESULT;
|
||||||
|
|
||||||
|
typedef LONG HRESULT;
|
||||||
|
#define S_OK ((HRESULT)0L)
|
||||||
|
#define S_FALSE ((HRESULT)1L)
|
||||||
|
#define E_FAIL ((HRESULT)0x80004005L)
|
||||||
|
#define E_OUTOFMEMORY ((HRESULT)0x8007000EL)
|
||||||
|
#define E_INVALIDARG ((HRESULT)0x80070057L)
|
||||||
|
#define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0)
|
||||||
|
#define FAILED(hr) (((HRESULT)(hr)) < 0)
|
||||||
|
|
||||||
typedef void* HANDLE;
|
typedef void* HANDLE;
|
||||||
struct HWND__;
|
struct HWND__;
|
||||||
typedef HWND__* HWND;
|
typedef HWND__* HWND;
|
||||||
@@ -91,6 +103,74 @@ typedef struct tagSIZE
|
|||||||
LONG cy;
|
LONG cy;
|
||||||
} SIZE, *PSIZE, *LPSIZE;
|
} SIZE, *PSIZE, *LPSIZE;
|
||||||
|
|
||||||
|
typedef union _LARGE_INTEGER
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
DWORD LowPart;
|
||||||
|
LONG HighPart;
|
||||||
|
};
|
||||||
|
LONGLONG QuadPart;
|
||||||
|
} LARGE_INTEGER, *PLARGE_INTEGER;
|
||||||
|
|
||||||
|
typedef struct _GUID
|
||||||
|
{
|
||||||
|
DWORD Data1;
|
||||||
|
WORD Data2;
|
||||||
|
WORD Data3;
|
||||||
|
BYTE Data4[8];
|
||||||
|
} GUID;
|
||||||
|
|
||||||
|
// The 40250 projects build with the multi-byte character set: TCHAR and the GDI structs are the
|
||||||
|
// `A` variants.
|
||||||
|
typedef char TCHAR;
|
||||||
|
#define LF_FACESIZE 32
|
||||||
|
|
||||||
|
typedef struct tagLOGFONTA
|
||||||
|
{
|
||||||
|
LONG lfHeight;
|
||||||
|
LONG lfWidth;
|
||||||
|
LONG lfEscapement;
|
||||||
|
LONG lfOrientation;
|
||||||
|
LONG lfWeight;
|
||||||
|
BYTE lfItalic;
|
||||||
|
BYTE lfUnderline;
|
||||||
|
BYTE lfStrikeOut;
|
||||||
|
BYTE lfCharSet;
|
||||||
|
BYTE lfOutPrecision;
|
||||||
|
BYTE lfClipPrecision;
|
||||||
|
BYTE lfQuality;
|
||||||
|
BYTE lfPitchAndFamily;
|
||||||
|
CHAR lfFaceName[LF_FACESIZE];
|
||||||
|
} LOGFONTA, LOGFONT, *PLOGFONT, *LPLOGFONT;
|
||||||
|
|
||||||
|
typedef struct tagTEXTMETRICA
|
||||||
|
{
|
||||||
|
LONG tmHeight;
|
||||||
|
LONG tmAscent;
|
||||||
|
LONG tmDescent;
|
||||||
|
LONG tmInternalLeading;
|
||||||
|
LONG tmExternalLeading;
|
||||||
|
LONG tmAveCharWidth;
|
||||||
|
LONG tmMaxCharWidth;
|
||||||
|
LONG tmWeight;
|
||||||
|
LONG tmOverhang;
|
||||||
|
LONG tmDigitizedAspectX;
|
||||||
|
LONG tmDigitizedAspectY;
|
||||||
|
BYTE tmFirstChar;
|
||||||
|
BYTE tmLastChar;
|
||||||
|
BYTE tmDefaultChar;
|
||||||
|
BYTE tmBreakChar;
|
||||||
|
BYTE tmItalic;
|
||||||
|
BYTE tmUnderlined;
|
||||||
|
BYTE tmStruckOut;
|
||||||
|
BYTE tmPitchAndFamily;
|
||||||
|
BYTE tmCharSet;
|
||||||
|
} TEXTMETRICA, TEXTMETRIC, *PTEXTMETRIC, *LPTEXTMETRIC;
|
||||||
|
|
||||||
|
struct HFONT__;
|
||||||
|
typedef HFONT__* HFONT;
|
||||||
|
|
||||||
#ifndef VOID
|
#ifndef VOID
|
||||||
#define VOID void
|
#define VOID void
|
||||||
#endif
|
#endif
|
||||||
@@ -133,4 +213,6 @@ static_assert(sizeof(BYTE) == 1 && sizeof(WORD) == 2 && sizeof(DWORD) == 4, "Win
|
|||||||
static_assert(sizeof(LONG) == 4 && sizeof(BOOL) == 4 && sizeof(UINT) == 4 && sizeof(INT) == 4, "Win32 signed widths");
|
static_assert(sizeof(LONG) == 4 && sizeof(BOOL) == 4 && sizeof(UINT) == 4 && sizeof(INT) == 4, "Win32 signed widths");
|
||||||
static_assert(sizeof(SHORT) == 2 && sizeof(FLOAT) == 4, "Win32 short/float widths");
|
static_assert(sizeof(SHORT) == 2 && sizeof(FLOAT) == 4, "Win32 short/float widths");
|
||||||
static_assert(sizeof(POINT) == 8 && sizeof(RECT) == 16, "Win32 POINT/RECT layout");
|
static_assert(sizeof(POINT) == 8 && sizeof(RECT) == 16, "Win32 POINT/RECT layout");
|
||||||
|
static_assert(sizeof(GUID) == 16 && sizeof(LARGE_INTEGER) == 8, "Win32 GUID/LARGE_INTEGER layout");
|
||||||
|
static_assert(sizeof(LOGFONTA) == 60 && sizeof(TEXTMETRICA) == 56, "Win32 GDI struct layout");
|
||||||
static_assert(sizeof(WPARAM) == sizeof(void*) && sizeof(HANDLE) == sizeof(void*), "handles stay pointer-sized");
|
static_assert(sizeof(WPARAM) == sizeof(void*) && sizeof(HANDLE) == sizeof(void*), "handles stay pointer-sized");
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
#pragma once
|
||||||
|
// Shim for <d3d8.h>: the D3D8 value types 40250 logic uses as data. Rendering goes through
|
||||||
|
// platform/, never through these declarations.
|
||||||
|
#include "../../D3DXMath.h"
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
#pragma once
|
||||||
|
// Shim for <d3d8types.h>; see d3d8.h.
|
||||||
|
#include "d3d8.h"
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
#pragma once
|
||||||
|
// Shim for <d3dx8.h>: platform-independent D3DX8 math (common/D3DXMath.h); D3DX objects are
|
||||||
|
// opaque, owned by platform/.
|
||||||
|
#include "d3d8.h"
|
||||||
|
|
||||||
|
struct ID3DXMesh;
|
||||||
|
typedef ID3DXMesh* LPD3DXMESH;
|
||||||
|
struct ID3DXMatrixStack;
|
||||||
|
typedef ID3DXMatrixStack* LPD3DXMATRIXSTACK;
|
||||||
|
|
||||||
|
// d3dx8tex.h filter flags
|
||||||
|
#define D3DX_DEFAULT ((UINT)-1)
|
||||||
|
#define D3DX_FILTER_NONE (1 << 0)
|
||||||
|
#define D3DX_FILTER_POINT (2 << 0)
|
||||||
|
#define D3DX_FILTER_LINEAR (3 << 0)
|
||||||
|
#define D3DX_FILTER_TRIANGLE (4 << 0)
|
||||||
|
#define D3DX_FILTER_BOX (5 << 0)
|
||||||
|
#define D3DX_FILTER_MIRROR_U (1 << 16)
|
||||||
|
#define D3DX_FILTER_MIRROR_V (2 << 16)
|
||||||
|
#define D3DX_FILTER_MIRROR_W (4 << 16)
|
||||||
|
#define D3DX_FILTER_MIRROR (7 << 16)
|
||||||
|
#define D3DX_FILTER_DITHER (8 << 16)
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
#pragma once
|
||||||
|
// Shim for Miles Sound System <mss.h>: the scalar types and opaque handles 40250's MilesLib
|
||||||
|
// headers name. Playback goes through platform/, never through these declarations.
|
||||||
|
#include "../../Win32Types.h"
|
||||||
|
|
||||||
|
typedef int32_t S32;
|
||||||
|
typedef uint32_t U32;
|
||||||
|
typedef float F32;
|
||||||
|
typedef int16_t S16;
|
||||||
|
typedef uint16_t U16;
|
||||||
|
typedef int8_t S8;
|
||||||
|
typedef uint8_t U8;
|
||||||
|
|
||||||
|
#define AILCALLBACK
|
||||||
|
#define AILEXPORT
|
||||||
|
|
||||||
|
struct _SAMPLE;
|
||||||
|
struct _STREAM;
|
||||||
|
struct _DIG_DRIVER;
|
||||||
|
struct _H3DSAMPLE;
|
||||||
|
typedef _SAMPLE* HSAMPLE;
|
||||||
|
typedef _STREAM* HSTREAM;
|
||||||
|
typedef _DIG_DRIVER* HDIGDRIVER;
|
||||||
|
typedef void* H3DPOBJECT;
|
||||||
|
typedef H3DPOBJECT H3DSAMPLE;
|
||||||
|
typedef U32 HPROVIDER;
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
#pragma once
|
||||||
|
// Shim for <dinput.h> on non-Windows targets; what 40250 logic uses from it is in <windows.h>.
|
||||||
|
#include "windows.h"
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
#pragma once
|
||||||
|
// Shim for <direct.h> on non-Windows targets; what 40250 logic uses from it is in <windows.h>.
|
||||||
|
#include "windows.h"
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
#pragma once
|
||||||
|
// Shim for <imagehlp.h> on non-Windows targets; what 40250 logic uses from it is in <windows.h>.
|
||||||
|
#include "windows.h"
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
// Shim for MSVC <malloc.h> on non-Windows targets. Linux/Android ship a <malloc.h> that their
|
||||||
|
// <stdlib.h> itself includes, so defer to it; macOS has none.
|
||||||
|
#if __has_include_next(<malloc.h>)
|
||||||
|
#include_next <malloc.h>
|
||||||
|
#else
|
||||||
|
#include <stdlib.h>
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
#pragma once
|
||||||
|
// Shim for <mmsystem.h> on non-Windows targets; what 40250 logic uses from it is in <windows.h>.
|
||||||
|
#include "windows.h"
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
#pragma once
|
||||||
|
// Shim for <process.h> on non-Windows targets; what 40250 logic uses from it is in <windows.h>.
|
||||||
|
#include "windows.h"
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
#pragma once
|
||||||
|
// Shim for <windows.h> on non-Windows targets: the Win32 scalar types and CRT spellings
|
||||||
|
// 40250 sources use (common/Win32Types.h, common/Win32Crt.h).
|
||||||
|
#include "../../Win32Types.h"
|
||||||
|
#include "../../Win32Crt.h"
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
// Shim for <winsock.h> on non-Windows targets: the BSD socket types under their Winsock names.
|
||||||
|
#include "windows.h"
|
||||||
|
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
|
typedef int SOCKET;
|
||||||
|
typedef struct sockaddr SOCKADDR;
|
||||||
|
typedef struct sockaddr_in SOCKADDR_IN;
|
||||||
|
typedef struct in_addr IN_ADDR;
|
||||||
|
#define INVALID_SOCKET (-1)
|
||||||
|
#define SOCKET_ERROR (-1)
|
||||||
Reference in New Issue
Block a user