plansys makesystem(seedtype *s) { plansys thissys; myuint pair1,pair2,pair3,pair4; uint16 longnameflag=((*s).w0)&64; char *pairs1 = &pairs[24]; /* start of pairs used by this routine */ thissys.x=(((*s).w1)>>8); thissys.y=(((*s).w0)>>8); thissys.govtype =((((*s).w1)>>3)&7); /* bits 3,4 &5 of w1 */ thissys.economy =((((*s).w0)>>8)&7); /* bits 8,9 &A of w0 */ if (thissys.govtype <=1) { thissys.economy = ((thissys.economy)|2); } thissys.techlev =((((*s).w1)>>8)&3)+((thissys.economy)^7); thissys.techlev +=((thissys.govtype)>>1); if (((thissys.govtype)&1)==1) thissys.techlev+=1; /* C simulation of 6502's LSR then ADC */ thissys.population = 4*(thissys.techlev) + (thissys.economy); thissys.population += (thissys.govtype) + 1; thissys.productivity = (((thissys.economy)^7)+3)*((thissys.govtype)+4); thissys.productivity *= (thissys.population)*8; thissys.radius = 256*(((((*s).w2)>>8)&15)+11) + thissys.x; thissys.goatsoupseed.a = (*s).w1 & 0xFF;; thissys.goatsoupseed.b = (*s).w1 >>8; thissys.goatsoupseed.c = (*s).w2 & 0xFF; thissys.goatsoupseed.d = (*s).w2 >> 8; pair1=2*((((*s).w2)>>8)&31); tweakseed(s); pair2=2*((((*s).w2)>>8)&31); tweakseed(s); pair3=2*((((*s).w2)>>8)&31); tweakseed(s); pair4=2*((((*s).w2)>>8)&31); tweakseed(s); /* Always four iterations of random number */ (thissys.name)[0]=pairs1[pair1]; (thissys.name)[1]=pairs1[pair1+1]; (thissys.name)[2]=pairs1[pair2]; (thissys.name)[3]=pairs1[pair2+1]; (thissys.name)[4]=pairs1[pair3]; (thissys.name)[5]=pairs1[pair3+1]; if(longnameflag) /* bit 6 of ORIGINAL w0 flags a four-pair name */ { (thissys.name)[6]=pairs1[pair4]; (thissys.name)[7]=pairs1[pair4+1]; (thissys.name)[8]=0; } else (thissys.name)[6]=0; stripout(thissys.name,'.'); return thissys; }
/* Generates a random name for a level */ char *makeLevelName() { const char *letpairs = "..LEXEGEZACEBISOUSESARMAINDIREA.ERATENBERALAVETIEDORQUANTEISRION"; char *buf; int i; buf = (char *)malloc(sizeof(char) * 9); memset(buf,0,sizeof(buf)); for (i = 0; i < 8; i++) { buf[i] = letpairs[randMap(0,strlen(letpairs)-1)]; } buf[8] = 0; stripout(buf,'.'); for (i = 1; i < 8; i++) { buf[i] = tolower(buf[i]); } return buf; }
/* * Split an RFC822-style address into userid, host, and full name * */ void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name) { int a; strcpy(user, ""); strcpy(node, CtdlGetConfigStr("c_fqdn")); strcpy(name, ""); if (rfc822 == NULL) return; /* extract full name - first, it's From minus <userid> */ strcpy(name, rfc822); stripout(name, '<', '>'); /* strip anything to the left of a bang */ while ((!IsEmptyStr(name)) && (haschar(name, '!') > 0)) strcpy(name, &name[1]); /* and anything to the right of a @ or % */ for (a = 0; name[a] != '\0'; ++a) { if (name[a] == '@') { name[a] = 0; break; } if (name[a] == '%') { name[a] = 0; break; } } /* but if there are parentheses, that changes the rules... */ if ((haschar(rfc822, '(') == 1) && (haschar(rfc822, ')') == 1)) { strcpy(name, rfc822); stripallbut(name, '(', ')'); } /* but if there are a set of quotes, that supersedes everything */ if (haschar(rfc822, 34) == 2) { strcpy(name, rfc822); while ((!IsEmptyStr(name)) && (name[0] != 34)) { strcpy(&name[0], &name[1]); } strcpy(&name[0], &name[1]); for (a = 0; name[a] != '\0'; ++a) if (name[a] == 34) { name[a] = 0; break; } } /* extract user id */ strcpy(user, rfc822); /* first get rid of anything in parens */ stripout(user, '(', ')'); /* if there's a set of angle brackets, strip it down to that */ if ((haschar(user, '<') == 1) && (haschar(user, '>') == 1)) { stripallbut(user, '<', '>'); } /* strip anything to the left of a bang */ while ((!IsEmptyStr(user)) && (haschar(user, '!') > 0)) strcpy(user, &user[1]); /* and anything to the right of a @ or % */ for (a = 0; user[a] != '\0'; ++a) { if (user[a] == '@') { user[a] = 0; break; } if (user[a] == '%') { user[a] = 0; break; } } /* extract node name */ strcpy(node, rfc822); /* first get rid of anything in parens */ stripout(node, '(', ')'); /* if there's a set of angle brackets, strip it down to that */ if ((haschar(node, '<') == 1) && (haschar(node, '>') == 1)) { stripallbut(node, '<', '>'); } /* If no node specified, tack ours on instead */ if ( (haschar(node, '@')==0) && (haschar(node, '%')==0) && (haschar(node, '!')==0) ) { strcpy(node, CtdlGetConfigStr("c_nodename")); } else { /* strip anything to the left of a @ */ while ((!IsEmptyStr(node)) && (haschar(node, '@') > 0)) strcpy(node, &node[1]); /* strip anything to the left of a % */ while ((!IsEmptyStr(node)) && (haschar(node, '%') > 0)) strcpy(node, &node[1]); /* reduce multiple system bang paths to node!user */ while ((!IsEmptyStr(node)) && (haschar(node, '!') > 1)) strcpy(node, &node[1]); /* now get rid of the user portion of a node!user string */ for (a = 0; node[a] != '\0'; ++a) if (node[a] == '!') { node[a] = 0; break; } } /* strip leading and trailing spaces in all strings */ striplt(user); striplt(node); striplt(name); /* If we processed a string that had the address in angle brackets * but no name outside the brackets, we now have an empty name. In * this case, use the user portion of the address as the name. */ if ((IsEmptyStr(name)) && (!IsEmptyStr(user))) { strcpy(name, user); } }