feat(network): 集成ENet库并实现局域网联机对战功能

- 添加ENet库作为网络通信基础,替换原有的原生Socket实现
- 扩展游戏模式支持局域网联机对战(PvP网络模式)
- 重构网络状态结构以适配ENet的Host/Peer模型
- 在图形界面中添加网络对战菜单,支持创建房间和加入房间
- 实现网络消息的发送与接收,包括落子、断开连接等消息类型
- 为网络对战添加定时器轮询机制,实时处理网络事件
- 更新构建系统以编译和链接ENet库
This commit is contained in:
2026-03-17 17:57:04 +08:00
parent 0c9cfba81b
commit 88f12bcfea
50 changed files with 10969 additions and 241 deletions
+75
View File
@@ -0,0 +1,75 @@
/**
@file list.c
@brief ENet linked list functions
*/
#define ENET_BUILDING_LIB 1
#include "enet/enet.h"
/**
@defgroup list ENet linked list utility functions
@ingroup private
@{
*/
void
enet_list_clear (ENetList * list)
{
list -> sentinel.next = & list -> sentinel;
list -> sentinel.previous = & list -> sentinel;
}
ENetListIterator
enet_list_insert (ENetListIterator position, void * data)
{
ENetListIterator result = (ENetListIterator) data;
result -> previous = position -> previous;
result -> next = position;
result -> previous -> next = result;
position -> previous = result;
return result;
}
void *
enet_list_remove (ENetListIterator position)
{
position -> previous -> next = position -> next;
position -> next -> previous = position -> previous;
return position;
}
ENetListIterator
enet_list_move (ENetListIterator position, void * dataFirst, void * dataLast)
{
ENetListIterator first = (ENetListIterator) dataFirst,
last = (ENetListIterator) dataLast;
first -> previous -> next = last -> next;
last -> next -> previous = first -> previous;
first -> previous = position -> previous;
last -> next = position;
first -> previous -> next = first;
position -> previous = last;
return first;
}
size_t
enet_list_size (ENetList * list)
{
size_t size = 0;
ENetListIterator position;
for (position = enet_list_begin (list);
position != enet_list_end (list);
position = enet_list_next (position))
++ size;
return size;
}
/** @} */