tp command enchanted, update to latest sdk, resolve warnings

This commit is contained in:
yangzhi 2019-10-10 20:18:02 +08:00
parent cc5b550cef
commit 5495d67027
36 changed files with 783 additions and 85 deletions

View File

@ -2,7 +2,11 @@
#define IDA_CONSTANTS_H
#define _BYTE unsigned char
#define __int64 long long int
#ifndef __int64
#define __int64 long long int
#endif
#define __int16 short
#endif

View File

@ -1,16 +1,16 @@
#include "ChatWidget.h"
#include "../cwmods.h"
void cube::ChatWidget::PrintMessage(wchar_t* message, FloatRGBA* color){
void cube::ChatWidget::PrintMessage(const wchar_t* message, FloatRGBA* color){
msvc::wstring str(message);
((void(*)(cube::ChatWidget*, msvc::wstring*, FloatRGBA*))CWBase()+0x26BF10)(this, &str, color);
}
void cube::ChatWidget::PrintMessage(wchar_t* message) {
void cube::ChatWidget::PrintMessage(const wchar_t* message) {
this->PrintMessage(message, 255, 255, 255);
}
void cube::ChatWidget::PrintMessage(wchar_t* message, char red, char green, char blue){
void cube::ChatWidget::PrintMessage(const wchar_t* message, char red, char green, char blue){
float f_red = (float)red / 255.0;
float f_green = (float)green / 255.0;
float f_blue = (float)blue / 255.0;

View File

@ -12,9 +12,9 @@ class ChatWidget : public plasma::Widget {
char end;
void PrintMessage(wchar_t* message, FloatRGBA* color);
void PrintMessage(wchar_t* message);
void PrintMessage(wchar_t* message, char red, char green, char blue);
void PrintMessage(const wchar_t* message, FloatRGBA* color);
void PrintMessage(const wchar_t* message);
void PrintMessage(const wchar_t* message, char red, char green, char blue);
};
}

View File

@ -5,6 +5,8 @@
#include "../common/LongVector3.h"
#include "../common/FloatVector3.h"
#include "../common/ByteRGBA.h"
#include "../msvc/vector.h"
#include "ItemStack.h"
namespace cube {
class Creature {
@ -20,27 +22,82 @@ namespace cube {
FloatVector3 retreat;
float head_rotation;
unsigned int flags;
char stats_based_on_level;
char hostility_type;
char field_61;
char field_62;
char field_63;
char field_64;
char field_65;
char field_66;
char field_67;
unsigned int current_ability;
int race;
BYTE current_ability;
float time_since_ability;
int hit_combo;
float time_since_hit;
__int16 field_78;
ByteRGBA hair_color;
_BYTE gap7E[198];
char padding_7E;
char padding_7F;
unsigned int flags2;
float graphics_scale;
float hitbox_scale;
float physics_scale;
__int16 head_model;
__int16 hair_model;
__int16 hands_model;
__int16 feet_model;
__int16 chest_model;
__int16 tail_model;
__int16 shoulder_model;
__int16 wings_model;
float head_scale;
float chest_scale;
float hands_scale;
float feet_scale;
float unknown_scale;
float weapon_scale;
float tail_scale;
float shoulder_scale;
float wing_scale;
float chest_rotation;
FloatVector3 hands_rotation;
float feet_rotation;
float wings_rotation;
float unknown_rotation;
FloatVector3 chest_position;
FloatVector3 head_position;
FloatVector3 hands_position;
FloatVector3 feet_position;
FloatVector3 unknown_position;
FloatVector3 wings_position;
unsigned int movement_flags;
float roll_time;
float stun_time;
float unknown_time;
float slowed_time;
float sprint_time;
int field_140;
unsigned int level;
_BYTE gap148[4];
char classType;
_BYTE gap14D[2059];
int XP;
unsigned __int8 classType;
char specialization;
_BYTE gap14E[10];
char charge;
_BYTE gap159[27];
FloatVector3 attack_rotation;
float HP;
float float_184;
float MP;
float stealth;
_BYTE gap190[552];
cube::Item chest_armor;
cube::Item feet_armor;
cube::Item hands_armor;
cube::Item shoulder_armor;
cube::Item left_weapon;
cube::Item right_weapon;
_BYTE gap778[480];
char name[16];
_BYTE gap968[500];
_BYTE gap968[136];
msvc::vector<msvc::vector<cube::ItemStack>> inventory_tabs;
_BYTE gapA08[340];
int climbing_speed;
int swimming_speed;
int diving_skill;
@ -50,6 +107,7 @@ namespace cube {
int lamp_diameter;
_BYTE gapB78[2687];
char end;
};
}

View File

@ -10,12 +10,12 @@ cube::Game* cube::GetGame() {
return *(cube::Game**)(CWBase() + 0x551A80);
}
void cube::Game::PrintMessage(wchar_t* message, FloatRGBA* color) {
void cube::Game::PrintMessage(const wchar_t* message, FloatRGBA* color) {
this->gui.chat_widget->PrintMessage(message, color);
}
void cube::Game::PrintMessage(wchar_t* message) {
void cube::Game::PrintMessage(const wchar_t* message) {
this->gui.chat_widget->PrintMessage(message);
}
void cube::Game::PrintMessage(wchar_t* message, char red, char green, char blue) {
void cube::Game::PrintMessage(const wchar_t* message, char red, char green, char blue) {
this->gui.chat_widget->PrintMessage(message, red, green, blue);
}

View File

@ -70,9 +70,9 @@ namespace cube {
cube::Database database_1;
cube::Creature* GetPlayer();
void PrintMessage(wchar_t* message, FloatRGBA* color);
void PrintMessage(wchar_t* message);
void PrintMessage(wchar_t* message, char red, char green, char blue);
void PrintMessage(const wchar_t* message, FloatRGBA* color);
void PrintMessage(const wchar_t* message);
void PrintMessage(const wchar_t* message, char red, char green, char blue);
};
Game* GetGame();
}

9
cwmods/cube/Item.cpp Normal file
View File

@ -0,0 +1,9 @@
#include "Item.h"
cube::Item::Item(){
}
cube::Item::Item(char category, int id) {
this->category = category;
this->id = id;
}

30
cwmods/cube/Item.h Normal file
View File

@ -0,0 +1,30 @@
#ifndef ITEM_H
#define ITEM_H
#include "Spirit.h"
namespace cube {
class Item {
public:
char category;
char field_1;
char field_2;
char field_3;
int id;
unsigned int modifier;
int region;
int field_10;
char rarity;
int field_18;
char material;
cube::Spirit spirits[32];
char num_spirits;
char field_9E;
char field_9F;
Item();
Item(char category, int id);
};
}
#endif // ITEM_H

View File

@ -0,0 +1,9 @@
#include "ItemStack.h"
#include "Item.h"
cube::ItemStack::ItemStack() {
}
cube::ItemStack::ItemStack(int quantity, cube::Item item) {
this->quantity = quantity;
this->item = item;
}

17
cwmods/cube/ItemStack.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef ITEMSTACK_H
#define ITEMSTACK_H
#include "Item.h"
namespace cube {
class ItemStack {
public:
int quantity;
cube::Item item;
ItemStack();
ItemStack(int quantity, cube::Item item);
};
}
#endif // ITEMSTACK_H

1
cwmods/cube/Spirit.cpp Normal file
View File

@ -0,0 +1 @@
#include "Spirit.h"

14
cwmods/cube/Spirit.h Normal file
View File

@ -0,0 +1,14 @@
#ifndef SPIRIT_H
#define SPIRIT_H
namespace cube {
class Spirit {
public:
char x;
char y;
char z;
char material;
};
}
#endif // SPIRIT_H

View File

@ -0,0 +1 @@
#include "SpriteManager.h"

View File

@ -0,0 +1,30 @@
#ifndef SPRITEMANAGER_H
#define SPRITEMANAGER_H
#include "../IDA/types.h"
#include <windows.h>
#include "../gfx/D3D11Graphics.h"
namespace cube {
class SpriteManager {
public:
void *vtable;
gfx::D3D11Graphics *graphics;
void *sprite_map;
__int64 field_18;
__int64 field_20;
__int64 field_28;
__int64 field_30;
__int64 field_38;
__int64 field_40;
__int64 field_48;
__int64 field_50;
__int64 field_58;
__int64 field_60;
__int64 field_68;
__int64 field_70;
__int64 field_78;
};
}
#endif // SPRITEMANAGER_H

View File

@ -6,29 +6,35 @@
#include "Database.h"
#include <windows.h>
#include "../IDA/types.h"
#include "../msvc/list.h"
#include "SpriteManager.h"
namespace cube {
class World {
public:
void *vtable;
int day;
float time;
_BYTE gap10[416];
cube::World *self_ptr;
_BYTE gap1A8[72];
msvc::string world_name;
int seed;
_BYTE gap224[404];
cube::Database database;
CRITICAL_SECTION critical_section_0;
CRITICAL_SECTION critical_section_1;
CRITICAL_SECTION critical_section_2;
_BYTE gap440[8];
cube::Creature *local_creature;
_BYTE gap450[16];
BYTE zone_list[24];
_BYTE gap478[207];
char end;
void *vtable;
int day;
float time;
_BYTE gap10[48];
msvc::list<cube::Creature*> creatures;
_BYTE gap50[32];
cube::SpriteManager *spritemanager;
_BYTE gap78[312];
cube::World *self_ptr;
_BYTE gap1A8[72];
msvc::string world_name;
int seed;
_BYTE gap224[404];
cube::Database database;
CRITICAL_SECTION critical_section_0;
CRITICAL_SECTION critical_section_1;
CRITICAL_SECTION critical_section_2;
_BYTE gap440[8];
cube::Creature *local_creature;
_BYTE gap450[16];
BYTE zone_list[24];
_BYTE gap478[207];
char end;
};
}

View File

@ -2,16 +2,74 @@
#define WORLDMAP_H
#include "../IDA/types.h"
#include "../common/LongVector3.h"
#include <windows.h>
#include "World.h"
#include "../common/LongVector3.h"
#include "../plasma/D3D11Engine.h"
namespace cube {
class WorldMap {
public:
void *vtable;
_BYTE gap8[248];
cube::World *world;
plasma::D3D11Engine *d3d11engine;
__int64 field_18;
__int64 field_20;
__int64 field_28;
__int64 field_30;
__int64 field_38;
__int64 field_40;
__int64 field_48;
__int64 field_50;
__int64 field_58;
__int64 field_60;
__int64 field_68;
__int64 field_70;
__int64 field_78;
__int64 field_80;
__int64 field_88;
__int64 field_90;
__int64 field_98;
__int64 field_A0;
__int64 field_A8;
__int64 field_B0;
__int64 field_B8;
__int64 field_C0;
int field_C8;
_BYTE gapCC[52];
LongVector3 cursor_position;
_BYTE gap9[136];
int field_118;
int field_11C;
int field_120;
int field_124;
__int64 field_128;
__int64 field_130;
__int64 field_138;
__int64 field_140;
__int64 field_148;
int field_150;
int field_154;
int field_158;
int field_15C;
int field_160;
char field_164;
char field_165;
char field_166;
char field_167;
char field_168;
char field_169;
char field_16A;
char field_16B;
char field_16C;
char field_16D;
char field_16E;
char field_16F;
__int64 field_170;
__int64 field_178;
__int64 field_180;
__int64 field_188;
__int64 field_190;
__int64 field_198;
CRITICAL_SECTION critical_section_0;
CRITICAL_SECTION critical_section_1;
};

View File

@ -44,3 +44,17 @@ void WriteFarJMP(void* source, void* destination) {
VirtualProtect(location, 14, dwOldProtection, &dwOldProtection);
}
__declspec(noinline) void* operator new(size_t size) {
return ((void*(*)(size_t))CWBase()+0x392BAC)(size);
}
__declspec(noinline) void* operator new[](size_t size) {
return ((void*(*)(size_t))CWBase()+0x392BAC)(size);
}
__declspec(noinline) void operator delete(void* ptr) noexcept {
((void(*)(void*))CWBase()+0x392BE8)(ptr);
}
__declspec(noinline) void operator delete[](void* ptr) noexcept {
((void(*)(void*))CWBase()+0x392BE8)(ptr);
}

View File

@ -2,7 +2,7 @@
#define CWMODS_H
#include <cstdint>
#define EXPORT extern "C" __declspec(dllexport)
#define EXPORT extern "C" __declspec(dllexport) __declspec(noinline)
#include "IDA/types.h"
@ -19,21 +19,26 @@
#include "cube/Field.h"
#include "cube/Game.h"
#include "cube/Host.h"
#include "cube/Item.h"
#include "cube/ItemStack.h"
#include "cube/PlasmaHolder.h"
#include "cube/Speech.h"
#include "cube/SpriteManager.h"
#include "cube/World.h"
#include "cube/WorldMap.h"
#include "cube/Zone.h"
#include "cube/constants.h"
#include "gfx/Chunk.h"
#include "gfx/D3D11Graphics.h"
#include "gfx/D3D11Renderer.h"
#include "msvc/allocator.h"
#include "msvc/list.h"
#include "msvc/string.h"
#include "msvc/vector.h"
#include "msvc/wstring.h"
#include "plasma/Array.h"
#include "plasma/Attribute.h"
#include "plasma/ContinuousAttribute.h"
#include "plasma/D3D11Engine.h"
@ -45,6 +50,7 @@
#include "plasma/Node.h"
#include "plasma/Object.h"
#include "plasma/ObjectManager.h"
#include "plasma/Vector.h"
#include "plasma/Widget.h"
@ -57,4 +63,9 @@ EXPORT int ModMinorVersion();
void WriteByte(void* location, char val);
void WriteFarJMP(void* source, void* destination);
__declspec(noinline) void* operator new(size_t size);
__declspec(noinline) void* operator new[](size_t size);
__declspec(noinline) void operator delete(void* ptr) noexcept;
__declspec(noinline) void operator delete[](void* ptr) noexcept;
#endif // CWMODS_H

View File

@ -0,0 +1 @@
#include "D3D11Graphics.h"

View File

@ -0,0 +1,15 @@
#ifndef D3D11GRAPHICS_H
#define D3D11GRAPHICS_H
#include "../IDA/types.h"
namespace gfx {
class D3D11Graphics {
public:
void *vtable;
__int64 field_8;
__int64 field_10;
};
}
#endif // D3D11GRAPHICS_H

View File

@ -0,0 +1 @@
#include "allocator.h"

51
cwmods/msvc/allocator.h Normal file
View File

@ -0,0 +1,51 @@
#ifndef MSVC_ALLOCATOR_H
#define MSVC_ALLOCATOR_H
#include <iostream>
#include <stdexcept>
#include <cstdint>
#include <windows.h>
namespace msvc {
template <typename T>
struct allocator {
public:
typedef size_t size_type;
typedef T value_type;
typedef T& reference;
typedef T* pointer;
T* allocate( std::size_t n ) {
const static size_type alignment_size = 32;
const static size_type alignment_offset = (alignment_size-1) + sizeof(void*);
size_type new_allocation_size = n * sizeof(T);
pointer new_backing;
// Large arrays
if (new_allocation_size < 0x1000) {
new_backing = (pointer)new char[new_allocation_size];
} else {
new_allocation_size += 39;
char* large_array = new char[new_allocation_size];
new_backing = (pointer)((long long unsigned int)(large_array + alignment_offset) & ~(alignment_size-1));
((char**)(new_backing))[-1] = large_array;
}
return new_backing;
}
void deallocate( T* p, std::size_t n ) {
size_type old_allocation_size = n * sizeof(T);
if (old_allocation_size < 0x1000) {
delete[] p;
} else {
char* actual_allocation = ((char**)(p))[-1];
delete[] actual_allocation;
}
}
};
}
#endif // MSVC_ALLOCATOR_H

1
cwmods/msvc/list.cpp Normal file
View File

@ -0,0 +1 @@
#include "list.h"

126
cwmods/msvc/list.h Normal file
View File

@ -0,0 +1,126 @@
#ifndef MSVC_LIST_H
#define MSVC_LIST_H
#include <iostream>
#include <stdexcept>
#include <cstdint>
#include <windows.h>
#include "allocator.h"
namespace msvc {
template <typename T>
struct list {
class node {
public:
msvc::list<T>::node *next;
msvc::list<T>::node *prev;
T data;
node() {
this->next = nullptr;
this->prev = nullptr;
}
node( msvc::list<T>::node *prev, msvc::list<T>::node *next, T data) {
this->next = next;
this->prev = prev;
this->data = data;
}
};
public:
typedef size_t size_type;
typedef T value_type;
typedef T& reference;
typedef T* pointer;
// forward iterator
class iterator {
public:
typedef iterator self_type;
typedef int difference_type;
typedef std::forward_iterator_tag iterator_category;
iterator() {}
iterator(msvc::list<T>::node* ptr) : list_node(ptr) { }
self_type operator=(const self_type& other) { list_node = other.list_node; return *this; }
self_type operator++() { list_node = list_node->next; return *this; } // ++i
self_type operator++(int junk) { self_type i = *this; list_node = list_node->next; return i; } // i++
self_type operator--() { list_node = list_node->prev; return *this; }
self_type operator--(int junk) { self_type i = *this; list_node = list_node->prev; return i; }
reference operator*() { return list_node->data; }
pointer operator->() { return &list_node->data; }
bool operator==(const self_type& rhs) const { return list_node == rhs.list_node; }
bool operator!=(const self_type& rhs) const { return list_node != rhs.list_node; }
msvc::list<T>::node* list_node;
};
private:
msvc::list<T>::node *head;
size_type _size;
public:
reference front() {
return head->next->data;
}
reference back() {
return head->prev->data;
}
iterator begin() {
return iterator(head->next);
}
iterator end() {
return iterator(head);
}
size_type size() {
return _size;
}
size_type max_size() const noexcept {
// Silly, theoretical max container size.
return UINTPTR_MAX / sizeof(T);
}
iterator insert( iterator pos, const T& value ) {
list<T>::node* current_node = pos.list_node;
list<T>::node* previous_node = current_node->prev;
list<T>::node* new_node = new node(previous_node, current_node, value);
current_node->prev = new_node;
previous_node->next = new_node;
_size++;
return iterator(new_node);
}
iterator erase( iterator pos ) {
if (!size()) {
return end();
}
list<T>::node* current_node = pos.list_node;
list<T>::node* previous_node = current_node->prev;
list<T>::node* next_node = current_node->next;
next_node->prev = previous_node;
previous_node->next = next_node;
delete current_node;
return iterator(next_node);
}
};
}
#endif // MSVC_LIST_H

View File

@ -1,5 +1,5 @@
#ifndef STRING_H
#define STRING_H
#ifndef MSVC_STRING_H
#define MSVC_STRING_H
#include <cstdint>
namespace msvc {
@ -16,4 +16,4 @@ namespace msvc {
};
}
#endif // STRING_H
#endif // MSVC_STRING_H

View File

@ -1 +1 @@
#include "Vector.h"
#include "vector.h"

View File

@ -1,21 +1,209 @@
#ifndef VECTOR_H
#define VECTOR_H
// based on https://github.com/Andoryuuta/cwsdk/blob/master/cwsdk/msvc_bincompat/vector.h
#ifndef MSVC_VECTOR_H
#define MSVC_VECTOR_H
#include <iostream>
#include <stdexcept>
#include <cstdint>
#include <windows.h>
#include "allocator.h"
namespace msvc {
template <int N, typename T>
class Vector {
public:
T elements[N];
template <typename T>
struct vector {
private:
T* _start;
T* _end;
T* _cap;
T at(int i) {
return elements[i];
}
public:
typedef size_t size_type;
typedef T value_type;
typedef T& reference;
typedef T* pointer;
void assign(int i, T x) {
elements[i] = x;
}
};
// forward iterator
class iterator {
public:
typedef iterator self_type;
typedef int difference_type;
typedef std::forward_iterator_tag iterator_category;
iterator() {}
iterator(pointer ptr) : _ptr(ptr) { }
self_type operator=(const self_type& other) { _ptr = other._ptr; return *this; }
self_type operator++() { _ptr++; return *this; } // ++i
self_type operator++(int junk) { self_type i = *this; _ptr++; return i; } // i++
self_type operator--() { _ptr--; return *this; }
self_type operator--(int junk) { self_type i = *this; _ptr--; return i; }
reference operator*() { return *_ptr; }
pointer operator->() { return _ptr; }
bool operator==(const self_type& rhs) const { return _ptr == rhs._ptr; }
bool operator!=(const self_type& rhs) const { return _ptr != rhs._ptr; }
private:
pointer _ptr;
};
// const forward iterator
class const_iterator {
public:
typedef const_iterator self_type;
typedef int difference_type;
typedef std::forward_iterator_tag iterator_category;
const_iterator() {}
const_iterator(pointer ptr) : _ptr(ptr) { }
self_type operator++() { _ptr++; return *this; }
self_type operator++(int junk) { self_type i = *this; _ptr++; return i; }
self_type operator--() { _ptr--; return *this; }
self_type operator--(int junk) { self_type i = *this; _ptr--; return i; }
const value_type& operator*() { return *_ptr; }
const value_type* operator->() { return _ptr; }
bool operator==(const self_type& rhs) const { return _ptr == rhs._ptr; }
bool operator!=(const self_type& rhs) const { return _ptr != rhs._ptr; }
private:
pointer _ptr;
};
/* Constructors & Destructors start*/
vector() {
auto mem = (pointer)operator new(0);
_start = mem;
_end = mem;
_cap = mem;
reserve(1);
}
~vector() {
if (_start != nullptr) {
operator delete(_start);
}
}
/* Constructors & Destructors end*/
/* Element access methods start*/
reference at(size_type pos) {
if (pos > size()) {
throw std::out_of_range("index out of bounds");
}
return operator[](pos);
}
reference operator [](size_type pos) {
return _start[pos];
}
reference front() {
return *begin();
}
reference back() {
auto tmp = end();
tmp--;
return *tmp;
}
/* Element access methods end*/
/* Iterators methods start*/
iterator begin() {
return iterator(_start);
}
iterator end() {
return iterator(_end);
}
const_iterator begin() const {
return const_iterator(_start);
}
const_iterator end() const {
return const_iterator(_end);
}
/* Iterators methods end*/
/* Capacity methods start*/
bool empty() const {
return begin() == end();
}
size_type size() const {
return _end - _start;
}
size_type max_size() const {
// Silly, theoretical max container size.
return UINTPTR_MAX / sizeof(T);
}
void reserve(size_type new_cap) {
msvc::allocator<T> thisAllocator;
size_type old_capacity = capacity();
// No need to reserve more if we need less space than we have
if (new_cap <= old_capacity) {
return;
}
if (new_cap > max_size()) {
throw std::length_error("new_cap > max_size()");
}
// Create new backing array
pointer new_backing = thisAllocator.allocate(new_cap);
// Copy old contents to new array
size_type old_size = size();
memcpy((void*)new_backing, (void*)_start, old_size * sizeof(T));
// Remember old array
pointer old_backing = _start;
// Update the vector
_start = new_backing;
_end = new_backing + old_size;
_cap = new_backing + new_cap;
// Deallocate old array
thisAllocator.deallocate(old_backing, old_capacity);
}
size_type capacity() const {
return _cap - _start;
}
/* Capacity methods end*/
/* Modifer methods start*/
void push_back(const T& value) {
if (capacity() == 0) {
reserve(1);
}
else if (size() == capacity()) {
reserve(capacity() * 2);
}
_start[size()] = value;
_end++;
}
void pop_back() {
if (size() > 0) {
back().~T();
_end--;
}
}
void clear() noexcept {
_end = _start;
}
/* Modifer methods end*/
};
}
#endif // VECTOR_H
#endif // MSVC_VECTOR_H

View File

@ -1,7 +1,8 @@
#include "wstring.h"
#include <wchar.h>
#include <cstring>
msvc::wstring::wstring(wchar_t* str) {
msvc::wstring::wstring(const wchar_t* str) {
int len = wcslen(str) + 1;
wchar_t* data;
if (len >= 8) {

View File

@ -1,5 +1,5 @@
#ifndef WSTRING_H
#define WSTRING_H
#ifndef MSVC_WSTRING_H
#define MSVC_WSTRING_H
#include <cstdint>
namespace msvc {
@ -13,10 +13,10 @@ namespace msvc {
int64_t size;
int64_t cap;
wstring(wchar_t* str);
wstring(const wchar_t* str);
~wstring();
};
};
#endif // WSTRING_H
#endif // MSVC_WSTRING_H

View File

@ -3,13 +3,13 @@
#include "../IDA/types.h"
#include "Attribute.h"
#include "Array.h"
#include "../msvc/vector.h"
namespace plasma {
template <typename T>
class ContinuousAttribute : public plasma::Attribute {
public:
plasma::Array<T> data;
msvc::vector<T> data;
};
}

View File

@ -3,13 +3,13 @@
#include "../IDA/types.h"
#include "Attribute.h"
#include "Array.h"
#include "../msvc/vector.h"
namespace plasma {
template <typename T>
class DiscreteAttribute : public plasma::Attribute {
public:
plasma::Array<T> data;
msvc::vector<T> data;
};
}

View File

@ -1,13 +1,13 @@
#include "Display.h"
void plasma::Display::SetVisibility(int frame, int value) {
this->visibility.data.Set(frame, value);
this->visibility.data.at(frame) = value;
}
int plasma::Display::GetVisibility(int frame) {
return this->visibility.data.Get(frame);
return this->visibility.data.at(frame);
}
int plasma::Display::GetFrameCount() {
return this->visibility.data.Length();
return this->visibility.data.size();
}

View File

@ -5,15 +5,15 @@
#include "Keyable.h"
#include "DiscreteAttribute.h"
#include "ContinuousAttribute.h"
#include "../msvc/vector.h"
#include "Vector.h"
namespace plasma {
class Display : public plasma::Keyable {
public:
plasma::DiscreteAttribute<int> visibility;
plasma::DiscreteAttribute<int> clipping;
plasma::ContinuousAttribute<msvc::Vector<4, float>> fill;
plasma::ContinuousAttribute<msvc::Vector<4, float>> stroke;
plasma::ContinuousAttribute<plasma::Vector<4, float>> fill;
plasma::ContinuousAttribute<plasma::Vector<4, float>> stroke;
plasma::ContinuousAttribute<float> blurRadius;
_BYTE gap318[31];
char end;

1
cwmods/plasma/Vector.cpp Normal file
View File

@ -0,0 +1 @@
#include "Vector.h"

21
cwmods/plasma/Vector.h Normal file
View File

@ -0,0 +1,21 @@
#ifndef PLASMA_VECTOR_H
#define PLASMA_VECTOR_H
namespace plasma {
template <int N, typename T>
class Vector {
public:
T elements[N];
T Get(int i) {
return elements[i];
}
void Set(int i, T x) {
elements[i] = x;
}
};
}
#endif // PLASMA_VECTOR_H

View File

@ -17,7 +17,7 @@ float GetMilliseconds(int hour, int minute) {
return (hour * 60 * 60 * 1000) + (minute * 60 * 1000);
}
void CommandsModMessage(wchar_t message[]) {
void CommandsModMessage(const wchar_t* message) {
cube::Game* game = cube::GetGame();
game->PrintMessage(L"[");
game->PrintMessage(L"CommandsMod", 255, 140, 0);
@ -138,17 +138,17 @@ bool IsBlockedID(long long steamID) {
return false;
}
void PrintCommandName(wchar_t* name) {
void PrintCommandName(const wchar_t* name) {
cube::Game* game = cube::GetGame();
game->PrintMessage(name, 66, 161, 245);
}
void PrintCommandArg(wchar_t* arg) {
void PrintCommandArg(const wchar_t* arg) {
cube::Game* game = cube::GetGame();
game->PrintMessage(arg, 139, 209, 42);
}
void PrintCommand(wchar_t* command, wchar_t* args, wchar_t* message) {
void PrintCommand(const wchar_t* command, const wchar_t* args, const wchar_t* message) {
cube::Game* game = cube::GetGame();
PrintCommandName(command);
game->PrintMessage(L" ");
@ -170,6 +170,7 @@ void Help(int page) {
PrintCommand(L"/help", L"[number]", L"get help");
PrintCommand(L"/coords", L"", L"display world coords");
PrintCommand(L"/tp", L"<x> <y>", L"teleport in terms of map coords");
PrintCommand(L"/tp", L"<name>", L"teleport to the specified player location");
PrintCommand(L"/settime", L"<hour>:<minute>", L"set time");
PrintCommand(L"/name", L"<name>", L"change your name");
break;
@ -190,6 +191,7 @@ void Help(int page) {
PrintCommand(L"/tpmap", L"", L"Teleport to cursor position on map");
PrintCommand(L"/sethome", L"<alias>", L"Set player position as home");
PrintCommand(L"/home", L"<alias>", L"Teleport to home position by alias");
PrintCommand(L"/gui", L"chat <width> <height>", L"Set GUI Widget size");
break;
default:
CommandsModMessage( L"Invalid page number!\n");
@ -248,6 +250,34 @@ EXPORT int HandleChat(wchar_t* msg) {
CommandsModMessage(L"Teleporting.\n");
return 1;
} else if ( swscanf(msg, L"/gui chat %d %d", &targetx, &targety) == 2) {
game->gui.chat_widget->width = targetx;
game->gui.chat_widget->height = targety;
CommandsModMessage(L"GUI Chat Widget size changed.\n");
return 1;
} else if ( !wcsncmp(msg, L"/tp ", 4) ) {
wchar_t* wideName = &msg[4];
char* cName = new char[wcslen(wideName)+1];
int len = wcstombs(cName, wideName, 0x100);
if (len < 1) {
CommandsModMessage(L"Invalid name.\n");
return 1;
}
for(cube::Creature* creature: game->world->creatures) {
if (stricmp(creature->name, cName) == 0) {
cube::Creature* player = game->GetPlayer();
player->position.x = creature->position.x;
player->position.y = creature->position.y;
player->position.z = creature->position.z;
CommandsModMessage(L"Teleporting.\n");
return 1;
}
}
CommandsModMessage(L"Target not found.\n");
return 0;
} else if (!wcscmp(msg, L"/tpmap")) {
if(game->worldmap->cursor_position.x != 0x7FFFFFFF0000) {
LongVector3 position = game->worldmap->cursor_position;