From 8b784f2ede47f417b1bb0c573009fef401c49e33 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 2 Sep 2003 06:25:03 +0000 Subject: [PATCH] bot_qw.qc: make all bots "lose" a player that disconnects waypoint.r: make sure all waypoint data structs get initialized --- fbxa/bot_qw.qc | 14 ++++++++++++++ fbxa/waypoint.r | 23 +++++++++++++++-------- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/fbxa/bot_qw.qc b/fbxa/bot_qw.qc index dc47a30..56214fc 100644 --- a/fbxa/bot_qw.qc +++ b/fbxa/bot_qw.qc @@ -227,7 +227,21 @@ void () ClientDisconnected = { local integer cl_no = ClientNumber (@self); + local Bot p = NIL; + + p = players[cl_no]; players[cl_no] = NIL; + if (p) { + local entity e = p.ent; + local integer i; + for (i = 0; i < 32; i++) { + if (!players[i]) + continue; + if (players[i].ent.enemy == e) + [players[i] lost:p:0]; + } + } + [p dealloc]; }; // BotConnect and related functions. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= diff --git a/fbxa/waypoint.r b/fbxa/waypoint.r index 49372e6..4ab0f10 100644 --- a/fbxa/waypoint.r +++ b/fbxa/waypoint.r @@ -50,16 +50,23 @@ Array waypoint_array; @static entity waypoint_thinker; @static List waypoint_queue; +@static void () waypoint_init = +{ + waypoint_array = [[Array alloc] init]; + if (!waypoint_queue) + waypoint_queue = [[List alloc] init]; + if (!waypoint_thinker) { + waypoint_thinker = spawn (); + waypoint_thinker.classname = "waypoint_thinker"; + } +}; + @implementation Waypoint -(id)init { - if (!waypoint_array) { - waypoint_array = [[Array alloc] init]; - waypoint_queue = [[List alloc] init]; - waypoint_thinker = spawn (); - waypoint_thinker.classname = "waypoint_thinker"; - } + if (!waypoint_array) + waypoint_init (); return [super init]; } @@ -179,7 +186,7 @@ Waypoint Loading from file { if (waypoint_array) [waypoint_array free]; - waypoint_array = [[Array alloc] init]; + waypoint_init (); } +(Waypoint)waypointForNum:(integer)num @@ -193,7 +200,7 @@ Waypoint Loading from file { local integer i, tmp; - for (i = 0; i < 3; i++) { + for (i = 0; i < 4; i++) { tmp = (integer)links[i]; links[i] = [Waypoint waypointForNum:tmp]; }