adding multiplayer

This commit is contained in:
2026-04-15 06:57:15 -07:00
parent af639e62c3
commit 3a91db6321
32 changed files with 938 additions and 174 deletions

View File

@@ -1,6 +1,8 @@
#include "Centery.h"
#include "../../server_source/transactions.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int CenteryInit(void* self) {
entity* ent = self;
@@ -13,8 +15,42 @@ int CenteryUpdate(int arg, void* self) {
entity* e = self;
world* w = e->world;
centery* cen = e->data;
vec2 moveTo = {0,0};
vec2 moveTo = e->position;
int goodMove;
user_transaction pos_ut;
memset(&pos_ut, 0, sizeof(pos_ut));
printf("getting transaction\n");
//printf("Has Connection\n");
//printf("cli sock %d, entity sock ,\n", e->server->socket);
if(cen->cli->server.game_info.socket > 0) {
if(RecvUserTransaction(&pos_ut, e->server)) {
printf("Centery NG\n");
}else {
memcpy(&moveTo, pos_ut.userArg,sizeof(vec2));
printf("size of post_ut %d\n", pos_ut.argsize);
printf("move to %d,%d\n", moveTo.x,moveTo.y);
}
}
if(!EntityMove(e, &moveTo)) {
// st_move = (user_transaction){
// .userArg = &mv,
// .action = PlayerMove,
// .id = SERVER_T_USER_FLAG,
// .argsize = sizeof(mv),
//};
//w->wells[at(mv.x, mv.y, w)].cell = SetCell(6);
}
//do{
// goodMove = EntityMove(e,(vec2){e->position.x+ 0, e-> position.y + 1});
// if(goodMove == 1) {
@@ -64,7 +100,7 @@ int CenteryUpdate(int arg, void* self) {
printf("name of entity %s\n",e->name);
//printf("name of entity %s\n",e->name);
return 0;
}
@@ -78,7 +114,7 @@ int CenteryFree(void* self) {
entity* CreateCentery(int tear, int classification, world* w) {
entity* CreateCentery(int tear, client* cli, world* w) {
entity* ent = (entity*)malloc(sizeof(entity));
centery* cen = (centery*)malloc(sizeof(centery));
@@ -94,6 +130,7 @@ entity* CreateCentery(int tear, int classification, world* w) {
.str = 3,
.wis = 3,
.dex = 3,
.cli = cli,
};
*ent = (entity){
@@ -103,7 +140,7 @@ entity* CreateCentery(int tear, int classification, world* w) {
.tile = {
.simble = 'C',
.background = {0,0,0},
.forground = {0x3f,0x5f,0x10},
.forground = {0xff,0x10,0x10},
},
.position = (vec2){5,5},
.data = cen,