-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix crash when event queue is full (#521)
* each SpeechEvent needs to contain a copy of the speechtokens * added core changes * prevent memoryleak * add basic pol test * Remove extraneous prints in test * Address review comments - Refactor token encoding into a method --------- Co-authored-by: Kevin Eady <8634912+KevinEady@users.noreply.github.com>
- Loading branch information
Showing
12 changed files
with
236 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use os; | ||
use uo; | ||
|
||
const SYSEVENT_SPEECH := 0x00000001; | ||
|
||
program main(item) | ||
RegisterForSpeechEvents( item, 12 ); | ||
while (1) | ||
var ev := os::wait_for_event(30); | ||
case(ev.type) | ||
SYSEVENT_SPEECH: | ||
var tokens := ev.tokens; | ||
tokens.sort(); | ||
// This needs to match what's tested in test_client's say_something_with_tokens | ||
PrintTextAbove(item, $"source=[item] text=[{ev.text}] tokens=[{tokens}]"); | ||
endcase | ||
endwhile | ||
endprogram |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use npc; | ||
use os; | ||
use uo; | ||
|
||
const SYSEVENT_SPEECH := 0x00000001; | ||
|
||
program ai() | ||
EnableEvents(SYSEVENT_SPEECH, 12); | ||
|
||
var queue_size := GetObjProperty(Self(), "EventSize"); | ||
if (queue_size != error) | ||
Set_Event_Queue_Size(queue_size); | ||
endif | ||
|
||
while (1) | ||
// We use wait_for_event(0) with Sleep() because events are not queued if | ||
// the script is _actively_ waiting for events. This forces queuing in order to | ||
// test issues with queued events. | ||
var ev := os::wait_for_event(0); | ||
|
||
case(ev.type) | ||
SYSEVENT_SPEECH: | ||
var tokens := ev.tokens; | ||
tokens.sort(); | ||
// This needs to match what's tested in test_client's say_something_with_tokens | ||
Say($"source=[npc] text=[{ev.text}] tokens=[{tokens}]"); | ||
endcase | ||
Sleep(1); | ||
endwhile | ||
endprogram |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters