P3NG0/src/client.h

91 lines
2.4 KiB
C
Raw Normal View History

2023-10-03 14:02:07 -04:00
#ifndef H_CLIENT
#define H_CLIENT
#include <vector>
#include <thread>
2023-10-03 18:35:30 -04:00
#include <fstream>
#include <stdlib.h>
2023-10-03 14:02:07 -04:00
#include "drone.h"
2023-10-04 03:31:22 -04:00
#include "acfile.h"
2023-10-03 14:02:07 -04:00
bool debug = false;
2023-10-03 18:27:25 -04:00
std::random_device rd;
std::mt19937 rng(rd());
2023-10-03 14:02:07 -04:00
2023-10-06 04:11:55 -04:00
const std::string user_agent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36";
2023-10-04 03:31:22 -04:00
std::string confFile = "conf/bot.conf";
ACFile* mainConf;
ACFile* worldlist;
ACFile* replylist;
AMFile* messages;
2023-10-06 04:11:55 -04:00
ALFile* filth;
2023-10-03 18:35:30 -04:00
2023-10-03 14:02:07 -04:00
#define BUFFERSIZE 65535
bool autoOnline = false;
bool roomOnline = false;
unsigned char bufout[BUFFERSIZE] = {0};
int randWait;
int autosock;
int roomsock;
std::thread aRecv_t;
std::thread rRecv_t;
std::thread rKeepAlive_t;
std::thread rAutoMsg_t;
uint8_t autoserver[4] = { 209, 240, 84, 122 };
uint16_t autoport = 6650;
uint8_t roomserver[4] = { 209, 240, 84, 122 };
uint16_t roomport = 5672;
std::string login_username;
std::string login_password;
std::string avatar = "avatar:pengo.mov";
// Needs to include dimension too
std::string room;
uint16_t roomID = 1;
int protocol = 24;
char* version = "1000000000";
int avatars = 253;
int keepAliveTime;
uint16_t xPos = 0;
uint16_t yPos = 0;
uint16_t zPos = 0;
uint16_t direction = 0;
uint16_t spin = 0;
std::map<char, char*> properties;
std::map<char, Drone> objects;
2023-10-03 18:27:25 -04:00
void loadConfig();
int deinit(int response);
2023-10-03 14:02:07 -04:00
void autoInit();
void roomInit();
void roomKeepAlive();
void autoRandMessage();
void reciever(int *sock, uint16_t port);
void sessInit(int *sock, std::string username, std::string password);
void sessExit(int *sock);
void constructPropertyList(int type, std::map<int, char*> props, unsigned char* snd);
2023-10-03 14:02:07 -04:00
void readPropertyList(unsigned char* in);
std::map<char, char*> readOldPropertyList(unsigned char* in);
void setAvatar(int *sock, std::string avstr);
2023-10-03 14:02:07 -04:00
void roomIDReq(int *sock, std::string room);
void teleport(int *sock, int x, int y, int z, int rot);
void longloc(int *sock, int x, int y, int z, int rot);
void userEnter(char id);
void userExit(char id);
bool handleCommand(char* buffer, std::string from, std::string message);
bool handlePhrase(char* buffer, std::string from, std::string message);
2023-10-03 14:02:07 -04:00
void processText(int *sock, std::string username, std::string message);
void processWhisper(int *sock, std::string username, std::string message);
void sendChatMessage(int *sock, std::string msg);
void sendWhisperMessage(int *sock, std::string to, std::string msg);
void qsend(int *sock, unsigned char str[], bool queue);
2023-10-03 14:02:07 -04:00
#endif