Variables for 'Diabtoo':
Name Value Persist?
—————————— ———- ——–
sealedchest1 1 yes
sealedchest2 1 yes
sealedchest3 1 yes
sealedchest4 1 yes
sealedchest5 1 yes
sealedchest6 1 yes
sealedchest7 1 yes
sealedchest8 1 yes
sealedchest9 1 yes
sealedchest10 1 yes
sealedchest11 1 yes
sealedchest12 1 yes
sealedchest13 1 yes
sealedchest14 1 yes
sealedchest15 1 yes
sealedchest16 1 yes
sealedchest17 1 yes
sealedchest18 1 yes
sealedchest19 1 yes
sealedchest20 1 yes
sealedchest21 1 yes
sealedchest22 1 yes
sealedchest23 1 yes
sealedchest24 1 yes
sealedchest25 1 yes
sealedchest26 1 yes
sealedchest27 1 yes
sealedchest28 1 yes
sealedchest29 1 yes
sealedchest30 1 yes
sealedchest31 1 yes
sealedchest32 1 yes
sealedchest33 1 yes
sealedchest34 1 yes
sealedchest35 1 yes
sealedchest36 1 yes
sealedchest37 1 yes
sealedchest38 1 yes
sealedchest39 1 yes
sealedchest40 1 yes
hiddenimperialland 1 yes
prepromotionquest 54 yes
macalaniafinalquestjacob 7 yes
eotnewbienot 2 yes
eotnewbienew 1 yes
learncooking 7 yes
vicolanthunder 1 yes
dudefly 3 yes
treechoppingquest 10 yes
newyearsupplies 2 yes
newyearsevelorana 1 yes
inscriber 3 yes
Variables for 'Diabtoo':
Name Value Persist?
—————————— ———- ——–
sealedchest1 1010011010 yes
sealedchest2 1110010101 yes
sealedchest3 1001011011 yes
sealedchest4 1100111010 yes
hiddenimperialland 1 yes
prepromotionquest 54 yes
macalaniafinalquestjacob 7 yes
eotnewbienot 2 yes
eotnewbienew 1 yes
learncooking 7 yes
vicolanthunder 1 yes
dudefly 3 yes
treechoppingquest 10 yes
newyearsupplies 2 yes
newyearsevelorana 1 yes
inscriber 3 yes
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
#define BUCKETS 100
struct s_stringMap;
typedef struct s_stringMap {
const char *key;
const char *value;
int persist;
struct s_stringMap *next;
} stringMap;
unsigned int hashmap( const char *s )
{
unsigned int hash = 0;
if(!s || !*s) return 0;
do {
hash += *s;
hash *= 13;
s++;
} while (*s);
return hash % BUCKETS;
}
void hash_init( stringMap *map )
{
int i;
for(i = 0; i < BUCKETS; i++)
{
map[i].key = NULL;
map[i].value = NULL;
map[i].persist = FALSE;
map[i].next = NULL;
}
}
void hash_add( stringMap *map, const char *k, const char *v, int persist )
{
unsigned int hashcode;
stringMap *p;
hashcode = hashmap(k);
p = &map[hashcode];
while(p->key && strcmp(p->key, k) && p->next)
p = p->next;
if(!p->key) {
/* First node? */
p->key = (const char *)strdup(k);
p->value = (const char *)strdup(v);
p->persist = persist;
p->next = NULL;
} else if(!strcmp(p->key, k)) {
/* Found our match! */
if(p->value)
free((void *)p->value);
p->value = (const char *)strdup(v);
p->persist = persist;
} else {
/* New key */
p->next = (stringMap *)calloc(1, sizeof(stringMap));
p = p->next;
p->key = (const char *)strdup(k);
p->value = (const char *)strdup(v);
p->persist = persist;
p->next = NULL;
}
}
const char * hash_find(stringMap *map, const char *k)
{
unsigned int hashcode;
stringMap *p;
hashcode = hashmap(k);
p = &map[hashcode];
while(p->key && strcmp(p->key, k) && p->next)
p = p->next;
if(!p->key)
return NULL;
if(!strcmp(p->key, k))
return p->value;
return NULL;
}
int hash_is_persist(stringMap *map, const char *k)
{
if(hash_find(map, k) != NULL)
return TRUE;
else
return FALSE;
}
var1 = var->value / pow(10,length - posval);
lval2 = var1 % 10;
char result1 [MAX_INPUT_LENGTH];
int i = posval - 1;
sprintf(result1, "%ld", result);
xbuf[0] = '\0';
strcpy( xbuf, lval1 );
xbuf[i] = '\0';
strcat( xbuf, result1 );
strcat( xbuf, &lval1[(i+1)] );
if var $n s7questline == 5
and carries $n 345
say Ah, I see you have my ale! Go talk to John and he will do that favor I asked!
var $n s7questline = 6
break
endif
The numerical value that I'm pulling the digit from is a long int, and so that actually does restrict the number of characters the string can be to 10. This isn't a huge deal, but is there something I can use or something I can do to expand how big this number can go?
I know on things like max buffer or whatever, you can set a specified number or multiply the existing number.
Is there something doable when working with a value that's declared as a long?
I am assuming not, and I figure that what I would need to do is instead use 'long long' instead which seems to give me 19 spaces to work instead.
Am I shooting in the right direction? Is there any problems I may encounter anyone may think of right off?
Am I right that anywhere that the value may be printed using %ld I will need to convert to %ll?
Thanks in advance!
Just working on this last night and today, I've learned a lot of new things about C that I didn't know, and have a better grasp of some other things such as pointers and arrays.