Added some player message objects to start thinking about initial messages

This commit is contained in:
Warwick 2023-07-28 14:40:55 +01:00
parent 0b937b1d6a
commit e37181fe35
5 changed files with 31 additions and 10 deletions

View file

@ -1,4 +0,0 @@
message AMessage {
required int32 a=1;
optional int32 b=2;
}

View file

@ -2,6 +2,7 @@
// learn C. // learn C.
#include <error.h> #include <error.h>
#include <message.h>
#include <netinet/in.h> //sockaddr_in #include <netinet/in.h> //sockaddr_in
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> // Keeping for conversion functions #include <stdlib.h> // Keeping for conversion functions
@ -11,6 +12,8 @@
#include <sys/types.h> #include <sys/types.h>
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
int a = 1;
msg_amsg_test(a);
// Set up containers for file descriptor id's // Set up containers for file descriptor id's
int sockfd, clientsockfd, portno, errflag; int sockfd, clientsockfd, portno, errflag;
@ -34,10 +37,6 @@ int main(int argc, char *argv[]) {
error_crash("Can't open socket."); error_crash("Can't open socket.");
} }
error_warn("Can't open socket.");
int a = 1;
msg_amsg_test(a);
// Make sure there is no junk data in serve_addr // Make sure there is no junk data in serve_addr
bzero((char *)&serv_addr, sizeof serv_addr); bzero((char *)&serv_addr, sizeof serv_addr);

View file

@ -6,3 +6,10 @@
#include <string.h> #include <string.h>
void msg_amsg_test(int a); void msg_amsg_test(int a);
// Creates a socket set's it up to listen to listen on the specified port and
// returns the file descriptor
int msg_create_serv_connection(int portno);
// Creates a socket for the client and returns the file descriptor
int msg_accept_cli_connection();

View file

@ -1,3 +1,5 @@
syntax = "proto2";
message AMessage { message AMessage {
required int32 a = 1; required int32 a = 1;
optional int32 b = 2; optional int32 b = 2;

View file

@ -0,0 +1,17 @@
syntax = "proto2";
message Item {
required string id = 1;
}
message PlayerStatus {
required int32 id = 1;
optional int32 health = 2;
repeated Item inventory = 3;
}
// Sending plain text passwords is bad
message PlayerLogin {
required string username = 1;
required string password = 2;
}