diff --git a/neutral_example_implentation/opaygo_decoder/opaygo_decoder.c b/neutral_example_implentation/opaygo_decoder/opaygo_decoder.c index 5f0e43f..aebc222 100644 --- a/neutral_example_implentation/opaygo_decoder/opaygo_decoder.c +++ b/neutral_example_implentation/opaygo_decoder/opaygo_decoder.c @@ -1,6 +1,6 @@ #include "opaygo_decoder.h" -#define CHECK_BIT(variable, position) ((variable) & (1<<(position))) +#define CHECK_BIT(variable, position) (((variable) >> (position)) & 1) #define SET_BIT(variable,position,value) (variable & ~(1< MaxCount - MAX_TOKEN_JUMP) { + if (Count >= MaxCount - MAX_UNUSED_OLDER_TOKENS_COUNTER_SYNC) { return true; } } else if (Count > MaxCount) { return true; } else if(MAX_UNUSED_OLDER_TOKENS > 0 && Count != 0) { // We check that the count is in the range for unused older token or above - if (Count > MaxCount - MAX_UNUSED_OLDER_TOKENS) { + if (Count >= MaxCount - MAX_UNUSED_OLDER_TOKENS) { // If it is, we check that its ADD_CREDIT and that this count was not used if (Count % 2 == 0 && !IsInUsedCounts(Count, MaxCount, UsedCounts)) { return true; @@ -52,7 +52,7 @@ void MarkCountAsUsed(int Count, uint16_t *MaxCount, uint16_t *UsedCounts, int Va NewUsedCount = SET_BIT(NewUsedCount, (RelativeCount-1), 1); } // We move all of the tokens marked as used to their new position relative to the new max count - for(int i=RelativeCount+1; i < MAX_UNUSED_OLDER_TOKENS - RelativeCount; i++) { + for(uint16_t i=RelativeCount; i < MAX_UNUSED_OLDER_TOKENS; i++) { NewUsedCount = SET_BIT(NewUsedCount, i, CHECK_BIT(*UsedCounts, i-RelativeCount)); } *UsedCounts = NewUsedCount; @@ -77,7 +77,6 @@ TokenData GetDataFromToken(uint64_t InputToken, uint16_t *MaxCount, uint16_t *Us uint32_t CurrentToken = PutBaseInToken(StartingCode, TokenBase); uint32_t MaskedToken; int MaxCountTry; - int MinCountTry; int Value = DecodeBase(StartingCodeBase, TokenBase); TokenData output; bool ValidOlderToken = false; diff --git a/neutral_example_implentation/opaygo_decoder/opaygo_decoder.h b/neutral_example_implentation/opaygo_decoder/opaygo_decoder.h index be6ee8b..8ba15fc 100644 --- a/neutral_example_implentation/opaygo_decoder/opaygo_decoder.h +++ b/neutral_example_implentation/opaygo_decoder/opaygo_decoder.h @@ -14,6 +14,7 @@ #define MAX_TOKEN_JUMP 64 // This is a jump in count so up to twice as large as the number of tokens of the same type #define MAX_TOKEN_JUMP_COUNTER_SYNC 100 // This is a jump in count so up to twice as large as the number of tokens #define MAX_UNUSED_OLDER_TOKENS 16 // Maximum of 16 (8 tokens of the same type) +#define MAX_UNUSED_OLDER_TOKENS_COUNTER_SYNC 30 // Maximum of 30 counts older is allowed for counter sync struct TokenDataStruct { int Value;