| 1 | /*************************************************************************** |
| 2 | stack.cpp - description |
| 3 | ------------------- |
| 4 | begin : Sat Mar 16 2002 |
| 5 | copyright : (C) 2002 by Michael Bridak |
| 6 | email : [email protected] |
| 7 | $Id: stack.cpp,v 1.5 2003/04/14 05:51:04 mbridak Exp $ |
| 8 | ***************************************************************************/ |
| 9 | |
| 10 | /*************************************************************************** |
| 11 | * * |
| 12 | * This program is free software; you can redistribute it and/or modify * |
| 13 | * it under the terms of the GNU General Public License as published by * |
| 14 | * the Free Software Foundation; either version 2 of the License. * |
| 15 | * . * |
| 16 | * * |
| 17 | ***************************************************************************/ |
| 18 | |
| 19 | #include <stdlib.h> |
| 20 | #include "stack.h"cxx . . $ `<file>/src/stack.h`/ |
| 21 | |
| 22 | Stackcxx . . $ Stack#::Stackcxx . . $ Stack#Stack(49f6e7a06ebc5aa8).() |
| 23 | { |
| 24 | countercxx . . $ Stack#counter. = 0; |
| 25 | stackcxx . . $ Stack#stack. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 26 | top_of_stackcxx . . $ Stack#top_of_stack. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 27 | } |
| 28 | |
| 29 | |
| 30 | Stackcxx . . $ Stack#::~cxx . . $ Stack#`~Stack`(ced63f7c635d850d).Stackcxx . . $ Stack#() |
| 31 | { |
| 32 | STACK_DATAcxx . . $ STACK_DATA# *my_stack, *previous; |
| 33 | |
| 34 | my_stack = stackcxx . . $ Stack#stack.; |
| 35 | while (my_stack) |
| 36 | { |
| 37 | previous = my_stack; |
| 38 | my_stack = (STACK_DATAcxx . . $ STACK_DATA# *) my_stack->nextcxx . . $ $anonymous_type_2a3252a61388ed4a_0#next.; |
| 39 | freecxx . . $ free(bd21765a0afc8e3c).(previous); |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | int Stackcxx . . $ Stack#::RegisterEventcxx . . $ Stack#RegisterEvent(e6f1e707912c925d).(int direction, float signal, int ship_type) |
| 44 | { |
| 45 | STACK_DATAcxx . . $ STACK_DATA# *current; |
| 46 | |
| 47 | current = (STACK_DATAcxx . . $ STACK_DATA# *) calloccxx . . $ calloc(95acc9b79bb49189).(1, sizeof(STACK_DATAcxx . . $ STACK_DATA#)); |
| 48 | if (! current) |
| 49 | return FALSEcxx . . $ `src/stack.h:33:9`!; |
| 50 | |
| 51 | current->directioncxx . . $ $anonymous_type_2a3252a61388ed4a_0#direction. = direction; |
| 52 | current->signal_strengthcxx . . $ $anonymous_type_2a3252a61388ed4a_0#signal_strength. = signal; |
| 53 | current->ship_typecxx . . $ $anonymous_type_2a3252a61388ed4a_0#ship_type. = ship_type; |
| 54 | if (top_of_stackcxx . . $ Stack#top_of_stack.) |
| 55 | { |
| 56 | top_of_stackcxx . . $ Stack#top_of_stack.->nextcxx . . $ $anonymous_type_2a3252a61388ed4a_0#next. = current; |
| 57 | top_of_stackcxx . . $ Stack#top_of_stack. = current; |
| 58 | } |
| 59 | else // nothing in stack |
| 60 | { |
| 61 | top_of_stackcxx . . $ Stack#top_of_stack. = stackcxx . . $ Stack#stack. = current; |
| 62 | } |
| 63 | countercxx . . $ Stack#counter.++; |
| 64 | return TRUEcxx . . $ `src/stack.h:30:9`!; |
| 65 | } |
| 66 | |
| 67 | int Stackcxx . . $ Stack#::GetEventcxx . . $ Stack#GetEvent(b79619b7de9e70a7).(int event, int *rdirection, float *rsignal, int *ship_type) |
| 68 | { |
| 69 | int index = 1; |
| 70 | STACK_DATAcxx . . $ STACK_DATA# *current; |
| 71 | |
| 72 | current = stackcxx . . $ Stack#stack.; |
| 73 | while ( (current) && (index < event) ) |
| 74 | { |
| 75 | current = (STACK_DATAcxx . . $ STACK_DATA# *) current->nextcxx . . $ $anonymous_type_2a3252a61388ed4a_0#next.; |
| 76 | index++; |
| 77 | } |
| 78 | |
| 79 | if ( (index == event) && (current) ) |
| 80 | { |
| 81 | *rdirection = current->directioncxx . . $ $anonymous_type_2a3252a61388ed4a_0#direction.; |
| 82 | *ship_type = current->ship_typecxx . . $ $anonymous_type_2a3252a61388ed4a_0#ship_type.; |
| 83 | *rsignal = current->signal_strengthcxx . . $ $anonymous_type_2a3252a61388ed4a_0#signal_strength.; |
| 84 | return TRUEcxx . . $ `src/stack.h:30:9`!; |
| 85 | } |
| 86 | else |
| 87 | return FALSEcxx . . $ `src/stack.h:33:9`!; |
| 88 | } |
| 89 | |
| 90 | int Stackcxx . . $ Stack#::GetCountcxx . . $ Stack#GetCount(b126dc7c1de90089).() |
| 91 | { |
| 92 | return countercxx . . $ Stack#counter.; |
| 93 | } |
| 94 | |
| 95 | void Stackcxx . . $ Stack#::AdvanceSonarHistorycxx . . $ Stack#AdvanceSonarHistory(49f6e7a06ebc5aa8).() |
| 96 | { |
| 97 | STACK_DATAcxx . . $ STACK_DATA# *current, *previous; |
| 98 | current = stackcxx . . $ Stack#stack.; |
| 99 | while (current) |
| 100 | { |
| 101 | previous = current; |
| 102 | current = (STACK_DATAcxx . . $ STACK_DATA# *) current->nextcxx . . $ $anonymous_type_2a3252a61388ed4a_0#next.; |
| 103 | freecxx . . $ free(bd21765a0afc8e3c).(previous); |
| 104 | } |
| 105 | stackcxx . . $ Stack#stack. = top_of_stackcxx . . $ Stack#top_of_stack. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 106 | countercxx . . $ Stack#counter. = 0; |
| 107 | } |
| 108 | |
| 109 |