void *BucketAdd(bucketset_t set, char *name, void *value) { bucket_t *pbucket = DoFind(set, name); if (!pbucket) return NULL; if (pbucket->type == bt_int) return DoSet(pbucket, bint( (*(int *)DoGet(pbucket)) + (*(int *)value))); if (pbucket->type == bt_float) return DoSet(pbucket, bfloat( (*(double *)DoGet(pbucket)) + (*(double *)value))); //else, string -- just concat return BucketConcat(set, name, value); }
void *BucketAvg(bucketset_t set, char *name, void *value) { bucket_t *pbucket = DoFind(set, name); if (!pbucket) return NULL; if (pbucket->type == bt_int) return DoSet(pbucket, bint( AVG((*(int *)DoGet(pbucket)), (*(int *)value), pbucket->nvals))); if (pbucket->type == bt_float) return DoSet(pbucket, bfloat( AVG((*(double *)DoGet(pbucket)), (*(double *)value), pbucket->nvals))); //else, string -- just ignore return DoGet(pbucket); }
void VCvar::Register() { guard(VCvar::Register); VCommand::AddToAutoComplete(Name); DoSet(DefaultString); unguard; }
void *BucketSet(bucketset_t set, char *name,void *value) { bucket_t *pbucket = DoFind(set, name); if (!pbucket) return NULL; pbucket->nvals = 0; return DoSet(pbucket,value); }
void FBaseCVar::ForceSet (UCVarValue value, ECVarType type, bool nouserinfosend) { DoSet (value, type); if ((Flags & CVAR_USERINFO) && !nouserinfosend && !(Flags & CVAR_IGNORE)) D_UserInfoChanged (this); if (m_UseCallback) Callback (); Flags &= ~CVAR_ISDEFAULT; }
static void SetCacheLine( a_window *wnd, int row, int piece, wnd_line_piece *line ) { int i; for( i = 0; i < NUM_CACHE_ENTRIES; ++i ) { if( CacheLine[i].wnd == wnd && CacheLine[i].row == row && CacheLine[i].piece == piece ) { DoSet( i, wnd, row, piece, line ); return; } } for( i = 0; i < NUM_CACHE_ENTRIES; ++i ) { if( CacheLine[i].wnd == NULL ) { DoSet( i, wnd, row, piece, line ); return; } } ++CacheCurr; if( CacheCurr == NUM_CACHE_ENTRIES ) CacheCurr = 0; DoSet( CacheCurr, wnd, row, piece, line ); }
void *BucketNew(bucketset_t set, char *name, BucketType type, void *initialvalue) { bucket_t bucket; if (set == NULL) set = g_buckets; assert(set); bucket.name = goastrdup(name); bucket.type = type; bucket.vals.sval = NULL; bucket.nvals = 1; DoSet(&bucket, initialvalue); TableEnter(set->buckets,&bucket); return DoGet(DoFind(set, name)); }
void *BucketConcat(bucketset_t set, char *name, void *value) { bucket_t *pbucket = DoFind(set, name); char *temp, *s; if (!pbucket) return NULL; assert(pbucket->type == bt_string); s = DoGet(pbucket); temp = (char *)gsimalloc(strlen(s) + strlen(value) + 1); strcpy(temp,s); strcat(temp, value); DoSet(pbucket, temp); gsifree(temp); return DoGet(pbucket); }
void VCvar::Set(const VStr& AValue) { guard(VCvar::Set); if (Flags & CVAR_Latch) { LatchedString = AValue; return; } if (Flags & CVAR_Cheat && !Cheating) { GCon->Log(VStr(Name) + " cannot be changed while cheating is disabled"); return; } DoSet(AValue); Flags |= CVAR_Modified; unguard; }
static void GenerateCalEntries(int col) { int r; Token tok; char const *s; Parser p; /* Do some initialization first... */ ClearGlobalOmits(); DestroyOmitContexts(); DestroyVars(0); NumTriggered = 0; r=IncludeFile(InitialFile); if (r) { fprintf(ErrFp, "%s %s: %s\n", ErrMsg[E_ERR_READING], InitialFile, ErrMsg[r]); exit(1); } while(1) { r = ReadLine(); if (r == E_EOF) return; if (r) { Eprint("%s: %s", ErrMsg[E_ERR_READING], ErrMsg[r]); exit(1); } s = FindInitialToken(&tok, CurLine); /* Should we ignore it? */ if (NumIfs && tok.type != T_If && tok.type != T_Else && tok.type != T_EndIf && tok.type != T_IfTrig && ShouldIgnoreLine()) { /* DO NOTHING */ } else { /* Create a parser to parse the line */ CreateParser(s, &p); switch(tok.type) { case T_Empty: case T_Comment: break; case T_ErrMsg: r=DoErrMsg(&p); break; case T_Rem: r=DoCalRem(&p, col); break; case T_If: r=DoIf(&p); break; case T_IfTrig: r=DoIfTrig(&p); break; case T_Else: r=DoElse(&p); break; case T_EndIf: r=DoEndif(&p); break; case T_Include: r=DoInclude(&p); break; case T_Exit: DoExit(&p); break; case T_Set: r=DoSet(&p); break; case T_Fset: r=DoFset(&p); break; case T_UnSet: r=DoUnset(&p); break; case T_Clr: r=DoClear(&p); break; case T_Flush: r=DoFlush(&p); break; case T_Debug: break; /* IGNORE DEBUG CMD */ case T_Dumpvars: break; /* IGNORE DUMPVARS CMD */ case T_Banner: break; /* IGNORE BANNER CMD */ case T_Omit: r=DoOmit(&p); if (r == E_PARSE_AS_REM) { DestroyParser(&p); CreateParser(s, &p); r=DoCalRem(&p, col); } break; case T_Pop: r=PopOmitContext(&p); break; case T_Push: r=PushOmitContext(&p); break; case T_Preserve: r=DoPreserve(&p); break; case T_RemType: if (tok.val == RUN_TYPE) { r=DoRun(&p); break; } else { CreateParser(CurLine, &p); r=DoCalRem(&p, col); break; } /* If we don't recognize the command, do a REM by default */ /* Note: Since the parser hasn't been used yet, we don't */ /* need to destroy it here. */ default: CreateParser(CurLine, &p); r=DoCalRem(&p, col); break; } if (r && (!Hush || r != E_RUN_DISABLED)) Eprint("%s", ErrMsg[r]); /* Destroy the parser - free up resources it may be tying up */ DestroyParser(&p); } } }