Subversion Repositories WoWGM

Rev

Rev 32 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 32 Rev 36
Line 1... Line 1...
1
/****************************************************************************
1
/******************************************************************************
2
*
2
*
3
*		ClientGMCommands.cpp
3
*   ClientGMCommands.cpp
4
*
4
*
-
 
5
*
5
*		Written by Tristan Cormier
6
*   By Tristan Cormier - 11/20/2024
6
*		11.20.24
-
 
7
*
7
*
8
***/
8
***/
9
 
9
 
10
 
10
 
11
#include "pch.h"
11
#include "pch.h"
Line 15... Line 15...
15
 
15
 
16
#include <Console/ConsoleClient.h>
16
#include <Console/ConsoleClient.h>
17
#include <WowSvcs/ClientServices.h>
17
#include <WowSvcs/ClientServices.h>
18
 
18
 
19
 
19
 
20
/****************************************************************************
20
/******************************************************************************
21
*
21
*
22
*   Private
22
*   Private
23
*
23
*
24
***/
24
***/
25
 
25
 
26
//===========================================================================
26
//=============================================================================
27
char const* GetWord (char const* string, char* buffer, uint bufferchars) {
27
const char * GetWord (const char * string, char * buffer, uint bufferchars) {
28
	//TODO:
28
    //TODO:
29
  //ASSERT(string);
29
    //ASSERT(string);
30
  //ASSERT(buffer || bufferchars);
30
    //ASSERT(buffer || bufferchars);
31
	
31
 
32
  uint length = bufferchars - 1;
32
    uint length = bufferchars - 1;
33
  for (uint i = 0; i != length; i++) {
33
    for (uint i = 0; i != length; i++) {
34
    if (buffer[i] == ' ')
34
        if (buffer[i] == ' ')
35
      break;
35
            break;
36
    buffer[i] = *string;
36
        buffer[i] = *string;
37
    ++string;
37
        ++string;
38
  };
38
    };
39
  return string;    
39
    return string;    
40
}
40
}
41
 
41
 
42
 
42
 
43
/****************************************************************************
43
/******************************************************************************
44
*
44
*
45
*   Client GM Commands
45
*   Exports
46
*
46
*
47
***/
47
***/
48
 
48
 
49
//===========================================================================
49
//=============================================================================
50
BOOL CCommand_GMResurrect (char const* command, char const* arguments) {
50
BOOL CCommand_GMResurrect (const char * command, const char * arguments) {
51
	if (command && *command) {
51
    if (command && *command) {
52
		CDataStore msg;
52
        CDataStore msg;
53
		msg.Put(CMSG_GM_RESURRECT);
53
        msg.Put(CMSG_GM_RESURRECT);
54
		msg.PutString(arguments);
54
        msg.PutString(arguments);
55
		msg.Finalize();
55
        msg.Finalize();
56
 
56
 
57
		ClientServices_Send(&msg);
57
        ClientServices_Send(&msg);
58
	}
58
    }
59
	else
59
    else
60
		ConsoleWrite("Expected a player name", DEFAULT_COLOR);
60
        ConsoleWrite("Expected a player name", DEFAULT_COLOR);
61
	
-
 
62
	return TRUE;
-
 
63
}
-
 
64
 
61
 
65
//===========================================================================
-
 
66
BOOL CCommand_SetSecurity (char const* command, char const* arguments) {
-
 
67
  char name[49];
-
 
68
	GetWord(command, name, sizeof(name));
-
 
69
 
-
 
70
	int security = SStrToInt(command);
-
 
71
 
-
 
72
  ConsoleWriteA("Setting '%s' to security group %d", DEFAULT_COLOR, name, security);
-
 
73
 
-
 
74
  CDataStore msg;
-
 
75
  msg.Put(CMSG_SET_SECURITY_GROUP);
-
 
76
  msg.Put(security);
-
 
77
  msg.Finalize();
-
 
78
 
-
 
79
  ClientServices_Send(&msg);
-
 
80
  
-
 
81
  return TRUE;
62
    return TRUE;
82
}
63
}
83
 
64
 
-
 
65
//=============================================================================
-
 
66
BOOL CCommand_SetSecurity (const char * command, const char * arguments) {
-
 
67
    char name[49];
-
 
68
    GetWord(command, name, sizeof(name));
-
 
69
    
-
 
70
    int security = SStrToInt(command);
-
 
71
 
-
 
72
    ConsolePrintf("Setting '%s' to security group %d", name, security);
-
 
73
 
-
 
74
    CDataStore msg;
-
 
75
    msg.Put(CMSG_SET_SECURITY_GROUP);
-
 
76
    msg.Put(security);
-
 
77
    msg.Finalize();
84
 
78
 
85
/****************************************************************************
-
 
86
*
-
 
87
*   External
79
    ClientServices_Send(&msg);
88
*
-
 
89
***/
-
 
90
 
80
 
-
 
81
    return TRUE;
-
 
82
}
-
 
83
 
91
//===========================================================================
84
//=============================================================================
92
void GMClientCommands::Install () {
85
void GMClientCommands::Install () {
-
 
86
    ConsoleCommandRegister(
-
 
87
        "setsecurity",
-
 
88
        CCommand_SetSecurity,
-
 
89
        GM,
93
  ConsoleCommandRegister("setsecurity",CCommand_SetSecurity,GM,"Set another character's security group");
90
        "Set another character's security group"
-
 
91
    );
-
 
92
 
94
	ConsoleCommandRegister("resurrect",CCommand_GMResurrect,DEBUG,NOHELP);
93
    ConsoleCommandRegister("resurrect", CCommand_GMResurrect, DEBUG, NOHELP);
95
}
94
}
96
 
95
 
97
//===========================================================================
96
//=============================================================================
98
void GMClientCommands::Uninstall () {
97
void GMClientCommands::Uninstall () {
99
  ConsoleCommandUnregister("setsecurity");
98
    ConsoleCommandUnregister("setsecurity");
100
	ConsoleCommandUnregister("resurrect");
99
    ConsoleCommandUnregister("resurrect");
101
}
100
}
102
 
101
 
-
 
102
 
-
 
103
//===================================
-
 
104
// MIT License
-
 
105
//
-
 
106
// Copyright (c) 2024 by Tristan Cormier
-
 
107
//
-
 
108
// Permission is hereby granted, free of charge, to any person obtaining a copy
-
 
109
// of this software and associated documentation files (the "Software"), to deal
-
 
110
// in the Software without restriction, including without limitation the rights
-
 
111
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-
 
112
// copies of the Software, and to permit persons to whom the Software is
-
 
113
// furnished to do so, subject to the following conditions:
-
 
114
//
-
 
115
// The above copyright notice and this permission notice shall be included in
-
 
116
// all copies or substantial portions of the Software.
-
 
117
// 
-
 
118
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-
 
119
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-
 
120
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-
 
121
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-
 
122
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-
 
123
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-
 
124
// THE SOFTWARE.
-
 
125
//===================================
103
 
126