… (char*) …
char* c;
char * c;
char *c;
if ( condition1 == condition2 ) {
x = function();
} else {
x = altFunction();
}
if ( condition1 == condition2 )
{
x = function();
}
else
{
x = altFunction();
}
if (setsockopt( fd, SOL_SOCKET, SO_REUSEADDR, (char *) &x, sizeof(x) ) < 0)
if ( condition ) {
x = function();
}
else {
x = altFunction();
}
if ( condition )
{
someLogic();
someMoreLogic();
}
else
{
otherLogic();
moreOtherLogic();
}
if ( can_see_room(ch,room)
&& !room_is_private(room)
&& !IS_SET(room->room_flags, ROOM_PRIVATE)
&& !IS_SET(room->room_flags, ROOM_SOLITARY)
&& !IS_SET(room->room_flags, ROOM_SAFE)
&& (IS_NPC(ch) || IS_SET(ch->act,ACT_AGGRESSIVE)
|| !IS_SET(room->room_flags,ROOM_LAW)))
break;
/* random room selection procedure */
ROOM_INDEX_DATA *get_random_room(CHAR_DATA *ch)
{
/* top_room is the number of rooms loaded.
* room_index_hash[0..MAX_KEY_HASH] is the set of rooms.
* Each room is stored in rih[vnum % MAX_KEY_HASH].
*/
int hash_counts[MAX_KEY_HASH];
ROOM_INDEX_DATA *pRoomIndex = NULL;
int iHash = 0;
int target_room = 0;
int room_count = 0;
int steps = 0;
bool found = false;
int tries = 0;
/* First, we need to know how many rooms are in each bucket */
for ( iHash = 0; iHash < MAX_KEY_HASH; iHash++ )
{
for ( pRoomIndex = room_index_hash[iHash];
pRoomIndex != NULL;
pRoomIndex = pRoomIndex->next )
{
hash_counts[iHash]++;
}
}
do
{
/* Ok, let's see how many tries we need */
tries++;
/* Next, we pick a random number */
target_room = number_range(0, top_room);
/* Now, we figure out which bucket that is in */
for ( iHash = 0; iHash < MAX_KEY_HASH; iHash++ )
{
room_count += hash_counts[iHash];
if ( room_count > target_room )
break;
}
steps = hash_counts[iHash] - ( room_count - target_room );
/* Now, find the actual room */
for ( pRoomIndex = room_index_hash[iHash];
pRoomIndex != NULL;
pRoomIndex = pRoomIndex->next )
{
/* Walk the list to it */
if ( –steps > 0 )
continue;
/* Validate it */
if ( can_see_room(ch,pRoomIndex)
&& !room_is_private(pRoomIndex)
&& !IS_SET(pRoomIndex->room_flags, ROOM_PRIVATE)
&& !IS_SET(pRoomIndex->room_flags, ROOM_SOLITARY)
&& !IS_SET(pRoomIndex->room_flags, ROOM_SAFE)
&& ( !IS_SET(pRoomIndex->room_flags, ROOM_LAW)
|| IS_NPC(ch)
|| IS_SET(ch->act,ACT_AGGRESSIVE)
)
)
{
found = true;
break;
}
/* If it wasn't valid, maybe one of the adjacent ones is */
}
/* If not, we pick a new random number and try again */
} while ( !found && tries < 10 );
return pRoomIndex;
}
select vnum from rooms where not rooms.is_private and not rooms.is_solitary and not rooms.is_safe order by random() limit 1;
room_is_private <=> private && some_other_condition(s)
!room_is_private(room) && !IS_SET(room->room_flags, ROOM_PRIVATE)
(!private || !some_other_condition(s)) && !private
In any case, the style I do not like looks like this:
ie, no spaces at all.