int DoZillaDeathMelt(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; USERp u = User[SpriteNum]; static SWBOOL alreadydid = FALSE; if (RANDOM_RANGE(1000) > 800) SpawnGrenadeExp(SpriteNum); u->ID = ZILLA_RUN_R0; RESET(u->Flags, SPR_JUMPING|SPR_FALLING|SPR_MOVED); //DoMatchEverything(NULL, sp->lotag, ON); if (!SW_SHAREWARE && gs.MusicOn && !alreadydid) { PlaySong(0, RedBookSong[Level], TRUE, TRUE); alreadydid = TRUE; } //KeepActorOnFloor(SpriteNum); getzsofslope(sp->sectnum, sp->x, sp->y, &u->hiz, &u->loz); u->lo_sectp = §or[sp->sectnum]; u->hi_sectp = §or[sp->sectnum]; u->lo_sp = NULL; u->hi_sp = NULL; sp->z = u->loz; BossSpriteNum[2] = -2; return 0; }
u_int32_t anubis_random(const char *expression) { #define RANDOM_RANGE(low, high) \ ((u_int32_t)(random() % ((high)-(low)+(1)))+(low)) anubis_srand(); //get param char *buffer = anubis_parse_param("random", expression); if(!buffer) return 0; if(strchr(buffer, '-')) { u_int32_t low = 0; u_int32_t high = 0; if(sscanf(buffer, " %d - %d ", &low, &high) != 2) { anubis_err("random(): random range format is \"integer - interger\"\n"); return 0; }//end if if(low > high) { u_int32_t tmp = low; low = high; high = tmp; }//end if return RANDOM_RANGE(low, high); }//end if range else { if(!strcasecmp(buffer, "Official") || !strcasecmp(buffer, "Well-known")) { return RANDOM_RANGE(0, 1023); }//end if else if(!strcasecmp(buffer, "Unofficial") || !strcasecmp(buffer, "Registered")) { return RANDOM_RANGE(1024, 49151); }//end if else if(!strcasecmp(buffer, "Multiple use") || !strcasecmp(buffer, "Dynamic") || !strcasecmp(buffer, "Private") || !strcasecmp(buffer, "Ephemeral")) { return RANDOM_RANGE(49152, 65535); }//end if else if(!strcasecmp(buffer, "u_int8_t")) { return RANDOM_RANGE(0, UINT8_MAX); }//end if else if(!strcasecmp(buffer, "u_int16_t")) { return RANDOM_RANGE(0, UINT16_MAX); }//end if else if(!strcasecmp(buffer, "u_int32_t") || strlen(buffer) == 0) { //default return RANDOM_RANGE(0, (u_int64_t)UINT32_MAX); }//end if else { anubis_err("random(): \"%s\" unknown parameter\n", buffer); return 0; }//end if }//end if }//end anubis_random
void makePointList(void) { float angle, velocity, direction; int i; motion = 1; for (i=0; i<numPoints; i++) { pointList[i][0] = 0.0; pointList[i][1] = 0.0; pointList[i][2] = 0.0; pointTime[i] = 0.0; angle = (RANDOM_RANGE(60.0, 70.0)) * M_PI/180.0; direction = RANDOM_RANGE(0.0, 360.0) * M_PI/180.0; pointDirection[i][0] = cos(direction); pointDirection[i][1] = sin(direction); velocity = MEAN_VELOCITY + RANDOM_RANGE(-0.8, 1.0); pointVelocity[i][0] = velocity * cos(angle); pointVelocity[i][1] = velocity * sin(angle); colorList[i] = rand() % NUM_COLORS; } time = 0.0; }
void DecodePassword(char *pw) { int bak_DrawScreen = DrawScreen; int bak_randomseed = randomseed; int i; int len; DrawScreen = FALSE; randomseed = 1234L; Bstrupr(pw); len = strlen(pw); for (i = 0; i < len; i++) pw[i] -= RANDOM_RANGE(26); randomseed = bak_randomseed; DrawScreen = bak_DrawScreen; }
void EncodePassword(char *pw) { long bak_DrawScreen = DrawScreen; long bak_randomseed = randomseed; long i; long len; DrawScreen = FALSE; randomseed = 1234L; Bstrupr(pw); len = strlen(pw); for (i = 0; i < len; i++) pw[i] += RANDOM_RANGE(26); randomseed = bak_randomseed; DrawScreen = bak_DrawScreen; }
/*********************************************************************** ** FillTableDesc() ** ** This function will randomly fill in all the information needed in the ** TableDescription structure. ************************************************************************/ void FillTableDesc(TableDescription *TablePtr) { TableInfo *TPtr; KeyDef *KPtr; ColumnInfo *CPtr; short i,j; short temp; short AbortColumn; short ZerosumColumn; short LastIdColumn; short Column[SQL_MAX_COLUMNS]; short ColumnCount; short KeyLengthMax; short KeyLength; short ActualKeyColCount; TPtr=TablePtr->TableInfoPtr; /* build a list of all columns */ for(i=0;i<TPtr->NumOfCol;i++) Column[i]=i; ColumnCount=TPtr->NumOfCol; /* if entry seq. or relative table then the key column is always */ /* added by the system and is a system key and always column 0 */ /* need to adjust the column count to allow for the addition of */ /* a system key and still keep the same column count */ if(TPtr->Organization==ENTRY_SEQ || TPtr->Organization==RELATIVE_TABLE){ TPtr->KeyType=SYSTEM_KEY; ColumnCount--; } else { /* NOMAD cannot work with a key seq. table that has only a system */ /* key so, make the key type either primary or clustering */ if(RANDOM_T_OR_F) { TPtr->KeyType=PRIMARY_KEY; KeyLengthMax=255; } else { TPtr->KeyType=CLUSTERING_KEY; KeyLengthMax=247; } } /* Randomly pick a column to be a numeric data type for the abort column */ temp=RANDOM_NUM0(ColumnCount-1); AbortColumn=Column[temp]; CPtr=TPtr->ColPtr+AbortColumn; CPtr->DataType=RandomNumericType(); /* if type is NUMERIC, DECIMAL, or PIC then make sure the length */ /* and/or scale is set to a value NOMAD can use */ if((CPtr->DataType==TYPE_NUMERIC)||(CPtr->DataType==TYPE_DECIMAL)){ CPtr->DataTypeLen=RANDOM_RANGE(5,18); CPtr->DataTypeScale=0; } /* remove that column number from the list of column choices */ for(i=temp;i+1<ColumnCount;i++) Column[i]=Column[i+1]; ColumnCount--; /* Randomly pick a column to be a numeric data type for zerosum column */ temp=RANDOM_NUM0(ColumnCount-1); ZerosumColumn=Column[temp]; CPtr=TPtr->ColPtr+ZerosumColumn; CPtr->DataType=RandomNumericType(); /* if type is NUMERIC, DECIMAL, or PIC then make sure the length */ /* and/or scale is set to a value NOMAD can use */ if((CPtr->DataType==TYPE_NUMERIC)||(CPtr->DataType==TYPE_DECIMAL)){ CPtr->DataTypeLen=RANDOM_RANGE(5,18); CPtr->DataTypeScale=0; } /* remove that column number from the list of column choices */ for(i=temp;i+1<ColumnCount;i++) Column[i]=Column[i+1]; ColumnCount--; /* Randomly pick a column to be a numeric data type for last-id column */ temp=RANDOM_NUM0(ColumnCount-1); LastIdColumn=Column[temp]; CPtr=TPtr->ColPtr+LastIdColumn; CPtr->DataType=RandomNonDateTimeType(); /* if type is NUMERIC, DECIMAL, PIC, CHAR, VCHAR, or PICX then make */ /* sure the length and/or scale is set to a value NOMAD can use */ if((CPtr->DataType==TYPE_NUMERIC)|| (CPtr->DataType==TYPE_DECIMAL)|| (CPtr->DataType==TYPE_CHAR)|| (CPtr->DataType==TYPE_VARCHAR)){ CPtr->DataTypeLen=RANDOM_RANGE(5,18); CPtr->DataTypeScale=0; } /* remove that column number from the list of column choices */ for(i=temp;i+1<ColumnCount;i++) Column[i]=Column[i+1]; ColumnCount--; /* if a key seq. table then we have some work to do to set up the */ /* key field that NOMAD will use to keep track of records with */ if(TPtr->Organization==KEY_SEQ){ /* assign the key columns so that none of the three columns just picked */ /* will be used as part of the key. First, set up at least one */ /* column of the key to meet NOMAD's requirements */ /* make sure one of the key columns is a non-datetime type */ KPtr=TPtr->KeyPtr; temp=RANDOM_NUM0(ColumnCount-1); KPtr->ColNum=Column[temp]; CPtr=TPtr->ColPtr+(KPtr->ColNum); CPtr->DataType=RandomNonDateTimeType(); for(j=temp;j+1<ColumnCount;j++) Column[j]=Column[j+1]; ColumnCount--; KPtr++; /* if type is NUMERIC or DECIMAL, then make sure the length */ /* and/or scale is set to a value NOMAD can use */ if((CPtr->DataType==TYPE_NUMERIC)|| (CPtr->DataType==TYPE_DECIMAL)|| (CPtr->DataType==TYPE_CHAR)|| (CPtr->DataType==TYPE_VARCHAR)){ CPtr->DataTypeLen=RANDOM_RANGE(5,18); CPtr->DataTypeScale=0; } KeyLength=(short)CPtr->DataTypeLen; /* Now pick the rest of the key columns randomly */ /* loop until we have the number of key columns we wanted or until */ /* we run out of columns to choose from */ ActualKeyColCount=1; i=1; while(KeyLengthMax!=(TPtr->KeyType==PRIMARY_KEY ? 255 : 247) && (i<TPtr->KeyColCount) && (ColumnCount!=0)){ temp=RANDOM_NUM0(ColumnCount); KPtr->ColNum=Column[temp]; CPtr=TPtr->ColPtr+(KPtr->ColNum); FillColumnInfo(CPtr); /* see if this key column will make the total key length exceed */ /* the maximum key length. If it doesn't then we can use this one */ /* for part of the key. If it does, then randomly make up another */ /* set of column information until we get one we can use */ while(KeyLength+(CPtr->DataTypeLen) > KeyLengthMax){ /* clear column info */ memset(CPtr,-1,sizeof(ColumnInfo)); CPtr->CName[0] = NULL; CPtr->Literal = NULL; CPtr->CHeading[0] = NULL; /* Randomly create new column info */ FillColumnInfo(CPtr); } ActualKeyColCount++; KeyLength+=(short)CPtr->DataTypeLen; /* remove it from the list of column choices */ for(j=temp;j+1<ColumnCount;j++) Column[j]=Column[j+1]; ColumnCount--; KPtr++; i++; } /* end: while */ /* it might have been the case that we could not select the requested */ /* number of key columns because the maximum key length would have */ /* been exceeded no matter which combination of columns were chosen */ /* So, we'll adjust the key column count here to be the actual count */ TPtr->KeyColCount=ActualKeyColCount; } /* end: if KEY_SEQ */ /* Now just fill in the TableInfo part. The NomadInfo */ /* will be filled in later by CreateSQLTable() */ FillTableInfo(TablePtr->TableInfoPtr); } /* end: FillTableDesc() */