Fix bugs and add /name
This commit is contained in:
parent
02536fe278
commit
daea14395a
|
@ -21,7 +21,14 @@ namespace cube {
|
||||||
float head_rotation;
|
float head_rotation;
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
char stats_based_on_level;
|
char stats_based_on_level;
|
||||||
__declspec(align(8)) unsigned int current_ability;
|
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;
|
||||||
float time_since_ability;
|
float time_since_ability;
|
||||||
int hit_combo;
|
int hit_combo;
|
||||||
float time_since_hit;
|
float time_since_hit;
|
||||||
|
@ -31,7 +38,9 @@ namespace cube {
|
||||||
unsigned int level;
|
unsigned int level;
|
||||||
_BYTE gap148[4];
|
_BYTE gap148[4];
|
||||||
char classType;
|
char classType;
|
||||||
_BYTE gap14D[2575];
|
_BYTE gap14D[2059];
|
||||||
|
char name[16];
|
||||||
|
_BYTE gap968[500];
|
||||||
int climbing_speed;
|
int climbing_speed;
|
||||||
int swimming_speed;
|
int swimming_speed;
|
||||||
int diving_skill;
|
int diving_skill;
|
||||||
|
|
35
main.cpp
35
main.cpp
|
@ -2,6 +2,7 @@
|
||||||
#include "cwmods/cwmods.h"
|
#include "cwmods/cwmods.h"
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
float GetMilliseconds(int hour, int minute) {
|
float GetMilliseconds(int hour, int minute) {
|
||||||
|
@ -42,27 +43,47 @@ EXPORT int HandleChat(wchar_t* msg) {
|
||||||
float maxTime = GetMilliseconds(24, 0);
|
float maxTime = GetMilliseconds(24, 0);
|
||||||
float minTime = GetMilliseconds(0, 0);
|
float minTime = GetMilliseconds(0, 0);
|
||||||
|
|
||||||
if (targetMS > maxTime) targetMS = maxTime;
|
if (targetMS > maxTime)
|
||||||
else if (targetMS < minTime) targetMS = minTime;
|
targetMS = maxTime;
|
||||||
|
else if (targetMS < minTime)
|
||||||
|
targetMS = minTime;
|
||||||
|
|
||||||
world->time = targetMS;
|
world->time = targetMS;
|
||||||
|
|
||||||
swprintf(response, L"Changing time to %d:%02d.\n", targetHour % 24, targetMinute % 60);
|
swprintf(response, L"Changing time to %d:%02d.\n", targetHour % 24, targetMinute % 60);
|
||||||
CommandsModMessage(response);
|
CommandsModMessage(response);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
else if (!wcscmp(msg, L"/coords")){
|
} else if (!wcscmp(msg, L"/coords")) {
|
||||||
cube::Creature* player = game->GetPlayer();
|
cube::Creature* player = game->GetPlayer();
|
||||||
swprintf(response, L"World coordinates:\nX: %lld\nY: %lld\nZ: %lld\n", player->position.x, player->position.y, player->position.z);
|
swprintf(response, L"World coordinates:\nX: %lld\nY: %lld\nZ: %lld\n", player->position.x, player->position.y, player->position.z);
|
||||||
CommandsModMessage(response);
|
CommandsModMessage(response);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
else if ( swscanf(msg, L"/tp %d %d", &targetx, &targety) == 2){
|
} else if ( swscanf(msg, L"/tp %d %d", &targetx, &targety) == 2) {
|
||||||
cube::Creature* player = game->GetPlayer();
|
cube::Creature* player = game->GetPlayer();
|
||||||
player->position.x = MapCoordToDots(targetx);
|
player->position.x = MapCoordToDots(targetx);
|
||||||
player->position.y = MapCoordToDots(targety);
|
player->position.y = MapCoordToDots(targety);
|
||||||
swprintf(response, L"Teleporting.\n");
|
CommandsModMessage(L"Teleporting.\n");
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
} else if ( !wcsncmp(msg, L"/name ", 6) ) {
|
||||||
|
cube::Creature* player = game->GetPlayer();
|
||||||
|
wchar_t* wideName = &msg[6];
|
||||||
|
char newName[18];
|
||||||
|
memset(newName, 0, sizeof(newName));
|
||||||
|
int len = wcstombs(newName, wideName, 16);
|
||||||
|
if (len < 1) {
|
||||||
|
CommandsModMessage(L"Invalid name.\n");
|
||||||
|
}
|
||||||
|
else if (len >= 16) {
|
||||||
|
CommandsModMessage(L"Name too long!\n");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
strcpy(player->name, newName);
|
||||||
|
swprintf(response, L"You are now known as %s.\n", player->name);
|
||||||
CommandsModMessage(response);
|
CommandsModMessage(response);
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue