Ejemplo n.º 1
0
void amend()
{
	int i,j,k;
	double D;
	for( i=0; i<Nm; i++)
	{
		for( j=0; j<Ni; j++)
		{
			D1[j][i]=0;
		}
		for( j=0; j<No; j++)
		{
			D2[i][j]=0;
		}
	}
	for( i=0; i<Ni; i++)
	{
		for( j=0; j<Nm; j++)
		{
			for( k=0; k<L; k++)
			{
				D1[i][j] = Qm[k][j] * Pi[k][i] + D1[i][j];
			}
             D = D1[i][j] * D11[i][j]  ;//为D11付初值
			 a1[i][j] = newa( a1[i][j] , D );  // a 付初值
			 W1[i][j] = W1[i][j] + a1[i][j] * ( n * D1[i][j] + ( 1 - n ) * D11[i][j] );
			 D11[i][j] = D1[i][j];
		}
	}
    for( i=0; i<Nm; i++)
	{
		for( j=0; j<No; j++)
		{
			for( k=0; k<L; k++)
			{
				D2[i][j] = Qo[k][j] * Xm[k][i] + D2[i][j];
			}
			D = D2[i][j] * D22[i][j]  ;//为D11付初值
            a2[i][j] = newa( a2[i][j] , D ); 
			W2[i][j] = W2[i][j] + a2[i][j] * ( n * D2[i][j] + ( 1 - n ) * D22[i][j] );
			D22[i][j] = D2[i][j];
		}
	}
}
int dns_label_undo_idna(const char *encoded, size_t encoded_size, char *decoded, size_t decoded_max) {
#ifdef HAVE_LIBIDN
        size_t input_size, output_size;
        _cleanup_free_ uint32_t *input = NULL;
        _cleanup_free_ char *result = NULL;
        uint32_t *output = NULL;
        size_t w;

        /* To be invoked after unescaping */

        assert(encoded);
        assert(decoded);

        if (encoded_size < sizeof(IDNA_ACE_PREFIX)-1)
                return 0;

        if (memcmp(encoded, IDNA_ACE_PREFIX, sizeof(IDNA_ACE_PREFIX) -1) != 0)
                return 0;

        input = stringprep_utf8_to_ucs4(encoded, encoded_size, &input_size);
        if (!input)
                return -ENOMEM;

        output_size = input_size;
        output = newa(uint32_t, output_size);

        idna_to_unicode_44i(input, input_size, output, &output_size, 0);

        result = stringprep_ucs4_to_utf8(output, output_size, NULL, &w);
        if (!result)
                return -ENOMEM;
        if (w <= 0)
                return 0;
        if (w+1 > decoded_max)
                return -EINVAL;

        memcpy(decoded, result, w+1);
        return w;
#else
        return 0;
#endif
}
Ejemplo n.º 3
0
NakedMemory Dib32To24(int width, int height, NakedMemory& old, NakedMemory& alpha)
{
    if (width * 4 * height != old.GetSize())
    {
        LOGERROR("Dib size not correct!");
        return NakedMemory();
    }
    
    auto nrowbytes = round_4(width * 3);
    auto arowbytes = round_4(width);
    auto orowbytes = width * 4;
    NakedMemory newd(nrowbytes * height);
    NakedMemory newa(arowbytes * height);
    auto nrows = (uint8_t*)newd.Get();
    auto orows = (uint8_t*)old.Get();
    auto arows = (uint8_t*)newa.Get();
    for (int i = 0;i < height;i++)
    {
        auto pn = nrows;
        auto po = orows;
        auto pa = arows;
        for (int j = 0;j < width;j++)
        {
            pn[0] = po[0];
            pn[1] = po[1];
            pn[2] = po[2];
            *pa++ = po[3];
            pn += 3;
            po += 4;
        }
        nrows += nrowbytes;
        orows += orowbytes;
        arows += arowbytes;
    }
    alpha = std::move(newa);
    return std::move(newd);
}
Ejemplo n.º 4
0
main() {
	bool flat = false;
	//int *low, *high;
	vector_t light;

	surface_t screen;

	// this is a vector buffer, for the transformations
	// our only object have 5 vertexes, but we'll make space for 32 anyway
	vector_t *pbuffer;

	// off-screen surface buffer
	//u_char* sbuffer = (u_char*)malloc(MODE2_MAX);

	// our solid :)
	object_t triangle;


	heapinit (HPSIZE);
	
	pbuffer = newa(vector_t, 32);

	triangle.mesh = build_mesh();
	triangle.rot_x = triangle.rot_y = triangle.rot_z = 0;
	triangle.trans_x = triangle.trans_y = 0;
	triangle.trans_z = i2f(30);	// remember: we are using fixed-point numbers

	screen.data.ram = sbuffer;

	// polygon rendering buffers
	//low = newa(int, MODE2_HEIGHT);
	//high = newa(int, MODE2_HEIGHT);

	// light source
	light.x = light.y = light.z = i2f(1);
	vector_normalize(&light, &light);

	printf("spinning solid demo\n\n");

	printf("instructions:\n   press [UP] to toggle flat shading\n\n");

	printf("creating look-up tables, please wait\n");
	create_lookup_tables();

	// set screen to graphic mode
	set_color(15, 1, 1);
	set_mode(mode_2);
	fill(MODE2_ATTR, 0xF1, MODE2_MAX);

	//surface_line(&screen, 0, 0, 0, 0); // FIXME: won't compile without this crap

	while (!get_trigger(0)) {
		if (get_stick(0) == 1)
			flat = !flat;

		// rotate a bit
		triangle.rot_y += 2;
		triangle.rot_x += 3;
		triangle.rot_z += 1;

		// clear the off-screen buffer
		memset(sbuffer, 0, MODE2_MAX);	// [*] 

	//surface_line(screen, 0, 0, 10, 10);

		// render the object
		if (flat)
			//object_render_flatshading(&screen, &triangle, pbuffer, low, high, &light);
			object_render_flatshading(&screen, &triangle, pbuffer, stencil, &light);
		else
			object_render_wireframe(&screen, &triangle, pbuffer);

		// show the off-screen buffer
		//vwrite(screen.data.ram, 0, MODE2_MAX); // [*]
		msx_vwrite_direct(screen.data.ram, 0, MODE2_MAX);

		// [*] FIXME: there will be better ways of doing this (soon)
	}

	// go back to text mode
	set_mode(mode_0);

	// deallocate stuff

	mesh_delete(triangle.mesh);
	//free(sbuffer);
	//free(low);
	//free(high);
	//destroy_lookup_tables();
}
Ejemplo n.º 5
0
Archivo: y.tab.c Proyecto: 8l/inferno
int
yyparse(void)
{
	struct
	{
		YYSTYPE	yyv;
		int	yys;
	} yys[YYMAXDEPTH], *yyp, *yypt;
	short *yyxi;
	int yyj, yym, yystate, yyn, yyg;
	long yychar;
	YYSTYPE save1, save2;
	int save3, save4;

	save1 = yylval;
	save2 = yyval;
	save3 = yynerrs;
	save4 = yyerrflag;

	yystate = 0;
	yychar = -1;
	yynerrs = 0;
	yyerrflag = 0;
	yyp = &yys[-1];
	goto yystack;

ret0:
	yyn = 0;
	goto ret;

ret1:
	yyn = 1;
	goto ret;

ret:
	yylval = save1;
	yyval = save2;
	yynerrs = save3;
	yyerrflag = save4;
	return yyn;

yystack:
	/* put a state and value onto the stack */
	if(yydebug >= 4)
		fprint(2, "char %s in %s", yytokname(yychar), yystatname(yystate));

	yyp++;
	if(yyp >= &yys[YYMAXDEPTH]) {
		yyerror("yacc stack overflow");
		goto ret1;
	}
	yyp->yys = yystate;
	yyp->yyv = yyval;

yynewstate:
	yyn = yypact[yystate];
	if(yyn <= YYFLAG)
		goto yydefault; /* simple state */
	if(yychar < 0)
		yychar = yylex1();
	yyn += yychar;
	if(yyn < 0 || yyn >= YYLAST)
		goto yydefault;
	yyn = yyact[yyn];
	if(yychk[yyn] == yychar) { /* valid shift */
		yychar = -1;
		yyval = yylval;
		yystate = yyn;
		if(yyerrflag > 0)
			yyerrflag--;
		goto yystack;
	}

yydefault:
	/* default state action */
	yyn = yydef[yystate];
	if(yyn == -2) {
		if(yychar < 0)
			yychar = yylex1();

		/* look through exception table */
		for(yyxi=yyexca;; yyxi+=2)
			if(yyxi[0] == -1 && yyxi[1] == yystate)
				break;
		for(yyxi += 2;; yyxi += 2) {
			yyn = yyxi[0];
			if(yyn < 0 || yyn == yychar)
				break;
		}
		yyn = yyxi[1];
		if(yyn < 0)
			goto ret0;
	}
	if(yyn == 0) {
		/* error ... attempt to resume parsing */
		switch(yyerrflag) {
		case 0:   /* brand new error */
			yyerror("syntax error");
			yynerrs++;
			if(yydebug >= 1) {
				fprint(2, "%s", yystatname(yystate));
				fprint(2, "saw %s\n", yytokname(yychar));
			}

		case 1:
		case 2: /* incompletely recovered error ... try again */
			yyerrflag = 3;

			/* find a state where "error" is a legal shift action */
			while(yyp >= yys) {
				yyn = yypact[yyp->yys] + YYERRCODE;
				if(yyn >= 0 && yyn < YYLAST) {
					yystate = yyact[yyn];  /* simulate a shift of "error" */
					if(yychk[yystate] == YYERRCODE)
						goto yystack;
				}

				/* the current yyp has no shift onn "error", pop stack */
				if(yydebug >= 2)
					fprint(2, "error recovery pops state %d, uncovers %d\n",
						yyp->yys, (yyp-1)->yys );
				yyp--;
			}
			/* there is no state on the stack with an error shift ... abort */
			goto ret1;

		case 3:  /* no shift yet; clobber input char */
			if(yydebug >= 2)
				fprint(2, "error recovery discards %s\n", yytokname(yychar));
			if(yychar == YYEOFCODE)
				goto ret1;
			yychar = -1;
			goto yynewstate;   /* try again in the same state */
		}
	}

	/* reduction by production yyn */
	if(yydebug >= 2)
		fprint(2, "reduce %d in:\n\t%s", yyn, yystatname(yystate));

	yypt = yyp;
	yyp -= yyr2[yyn];
	yyval = (yyp+1)->yyv;
	yym = yyn;

	/* consult goto table to find next state */
	yyn = yyr1[yyn];
	yyg = yypgo[yyn];
	yyj = yyg + yyp->yys + 1;

	if(yyj >= YYLAST || yychk[yystate=yyact[yyj]] != -yyn)
		yystate = yyact[yyg];
	switch(yym) {
		
case 1:
#line	41	"asm.y"
{
		assem(yypt[-0].yyv.inst);
	} break;
case 2:
#line	47	"asm.y"
{ yyval.inst = nil; } break;
case 3:
#line	49	"asm.y"
{
		if(yypt[-0].yyv.inst != nil) {
			yypt[-0].yyv.inst->link = yypt[-1].yyv.inst;
			yyval.inst = yypt[-0].yyv.inst;
		}
		else
			yyval.inst = yypt[-1].yyv.inst;
	} break;
case 4:
#line	60	"asm.y"
{
		yypt[-0].yyv.inst->sym = yypt[-2].yyv.sym;
		yyval.inst = yypt[-0].yyv.inst;
	} break;
case 5:
#line	65	"asm.y"
{
		heap(yypt[-3].yyv.ival, yypt[-1].yyv.ival, yypt[-0].yyv.string);
		yyval.inst = nil;
	} break;
case 6:
#line	70	"asm.y"
{
		yyval.inst = nil;
	} break;
case 8:
#line	77	"asm.y"
{
		yyval.ival = yypt[-0].yyv.ival;
	} break;
case 9:
#line	81	"asm.y"
{
		yypt[-0].yyv.sym->value = heapid++;
		yyval.ival = yypt[-0].yyv.sym->value;
	} break;
case 10:
#line	88	"asm.y"
{ yyval.string = nil; } break;
case 11:
#line	90	"asm.y"
{
		yyval.string = yypt[-0].yyv.string;
	} break;
case 12:
#line	96	"asm.y"
{
		yyval.list = newi(yypt[-0].yyv.ival, nil);
	} break;
case 13:
#line	100	"asm.y"
{
		yyval.list = newi(yypt[-0].yyv.ival, yypt[-2].yyv.list);
	} break;
case 14:
#line	106	"asm.y"
{
		yyval.inst = ai(yypt[-3].yyv.ival);
		yyval.inst->src = yypt[-2].yyv.addr;
		yyval.inst->dst = yypt[-0].yyv.addr;
	} break;
case 15:
#line	112	"asm.y"
{
		yyval.inst = ai(yypt[-5].yyv.ival);
		yyval.inst->src = yypt[-4].yyv.addr;
		yyval.inst->reg = yypt[-2].yyv.addr;
		yyval.inst->dst = yypt[-0].yyv.addr;
	} break;
case 16:
#line	119	"asm.y"
{
		yyval.inst = ai(yypt[-3].yyv.ival);
		yyval.inst->src = yypt[-2].yyv.addr;
		yyval.inst->dst = yypt[-0].yyv.addr;
	} break;
case 17:
#line	125	"asm.y"
{
		yyval.inst = ai(yypt[-1].yyv.ival);
		yyval.inst->dst = yypt[-0].yyv.addr;
	} break;
case 18:
#line	130	"asm.y"
{
		yyval.inst = ai(yypt[-0].yyv.ival);
	} break;
case 19:
#line	136	"asm.y"
{
		data(DEFB, yypt[-2].yyv.ival, yypt[-0].yyv.list);
	} break;
case 20:
#line	140	"asm.y"
{
		data(DEFW, yypt[-2].yyv.ival, yypt[-0].yyv.list);
	} break;
case 21:
#line	144	"asm.y"
{
		data(DEFL, yypt[-2].yyv.ival, yypt[-0].yyv.list);
	} break;
case 22:
#line	148	"asm.y"
{
		data(DEFF, yypt[-2].yyv.ival, newi(dtocanon((double)yypt[-0].yyv.ival), nil));
	} break;
case 23:
#line	152	"asm.y"
{
		data(DEFF, yypt[-2].yyv.ival, newi(dtocanon(yypt[-0].yyv.fval), nil));
	} break;
case 24:
#line	156	"asm.y"
{
		if(strcmp(yypt[-0].yyv.sym->name, "Inf") == 0 || strcmp(yypt[-0].yyv.sym->name, "Infinity") == 0) {
			u.l = (uvlong)0x7ff00000<<32;
			data(DEFF, yypt[-2].yyv.ival, newi(dtocanon(u.d), nil));
		} else if(strcmp(yypt[-0].yyv.sym->name, "NaN") == 0) {
			u.l = ((uvlong)0x7fffffff<<32) | (uvlong)0xffffffffUL;
			data(DEFF, yypt[-2].yyv.ival, newi(dtocanon(u.d), nil));
		} else
			diag("bad value for real: %s", yypt[-0].yyv.sym->name);
	} break;
case 25:
#line	167	"asm.y"
{
		data(DEFF, yypt[-3].yyv.ival, newi(dtocanon(-(double)yypt[-0].yyv.ival), nil));
	} break;
case 26:
#line	171	"asm.y"
{
		data(DEFF, yypt[-3].yyv.ival, newi(dtocanon(-yypt[-0].yyv.fval), nil));
	} break;
case 27:
#line	175	"asm.y"
{
		if(strcmp(yypt[-0].yyv.sym->name, "Inf") == 0 || strcmp(yypt[-0].yyv.sym->name, "Infinity") == 0) {
			u.l = (uvlong)0xfff00000<<32;
			data(DEFF, yypt[-3].yyv.ival, newi(dtocanon(u.d), nil));
		} else
			diag("bad value for real: %s", yypt[-0].yyv.sym->name);
	} break;
case 28:
#line	183	"asm.y"
{
		data(DEFS, yypt[-2].yyv.ival, news(yypt[-0].yyv.string, nil));
	} break;
case 29:
#line	187	"asm.y"
{
		if(yypt[-2].yyv.sym->ds != 0)
			diag("%s declared twice", yypt[-2].yyv.sym->name);
		yypt[-2].yyv.sym->ds = yypt[-0].yyv.ival;
		yypt[-2].yyv.sym->value = dseg;
		dseg += yypt[-0].yyv.ival;
	} break;
case 30:
#line	195	"asm.y"
{
		ext(yypt[-4].yyv.ival, yypt[-2].yyv.ival, yypt[-0].yyv.string);
	} break;
case 31:
#line	199	"asm.y"
{
		mklink(yypt[-6].yyv.ival, yypt[-4].yyv.ival, yypt[-2].yyv.ival, yypt[-0].yyv.string);
	} break;
case 32:
#line	203	"asm.y"
{
		if(module != nil)
			diag("this module already defined as %s", yypt[-0].yyv.sym->name);
		else
			module = yypt[-0].yyv.sym;
	} break;
case 33:
#line	210	"asm.y"
{
		if(pcentry >= 0)
			diag("this module already has entry point %d, %d" , pcentry, dentry);
		pcentry = yypt[-2].yyv.ival;
		dentry = yypt[-0].yyv.ival;
	} break;
case 34:
#line	217	"asm.y"
{
		data(DEFA, yypt[-4].yyv.ival, newa(yypt[-2].yyv.ival, yypt[-0].yyv.ival));
	} break;
case 35:
#line	221	"asm.y"
{
		data(DIND, yypt[-2].yyv.ival, newa(yypt[-0].yyv.ival, 0));
	} break;
case 36:
#line	225	"asm.y"
{
		data(DAPOP, 0, newa(0, 0));
	} break;
case 37:
#line	229	"asm.y"
{
		ldts(yypt[-0].yyv.ival);
	} break;
case 38:
#line	233	"asm.y"
{
		excs(yypt[-0].yyv.ival);
	} break;
case 39:
#line	237	"asm.y"
{
		exc(yypt[-10].yyv.ival, yypt[-8].yyv.ival, yypt[-6].yyv.ival, yypt[-4].yyv.ival, yypt[-2].yyv.ival, yypt[-0].yyv.ival);
	} break;
case 40:
#line	241	"asm.y"
{
		etab(yypt[-2].yyv.string, yypt[-0].yyv.ival);
	} break;
case 41:
#line	245	"asm.y"
{
		etab(nil, yypt[-0].yyv.ival);
	} break;
case 42:
#line	249	"asm.y"
{
		source(yypt[-0].yyv.string);
	} break;
case 43:
#line	255	"asm.y"
{
		yyval.addr = aa(yypt[-0].yyv.ival);
		yyval.addr->mode = AXIMM;
		if(yyval.addr->val > 0x7FFF || yyval.addr->val < -0x8000)
			diag("immediate %d too large for middle operand", yyval.addr->val);
	} break;
case 44:
#line	262	"asm.y"
{
		if(yypt[-0].yyv.addr->mode == AMP)
			yypt[-0].yyv.addr->mode = AXINM;
		else
			yypt[-0].yyv.addr->mode = AXINF;
		if(yypt[-0].yyv.addr->mode == AXINM && (ulong)yypt[-0].yyv.addr->val > 0xFFFF)
			diag("register offset %d(mp) too large", yypt[-0].yyv.addr->val);
		if(yypt[-0].yyv.addr->mode == AXINF && (ulong)yypt[-0].yyv.addr->val > 0xFFFF)
			diag("register offset %d(fp) too large", yypt[-0].yyv.addr->val);
		yyval.addr = yypt[-0].yyv.addr;
	} break;
case 45:
#line	276	"asm.y"
{
		yyval.addr = aa(yypt[-0].yyv.ival);
		yyval.addr->mode = AIMM;
	} break;
case 46:
#line	281	"asm.y"
{
		yyval.addr = aa(0);
		yyval.addr->sym = yypt[-0].yyv.sym;
	} break;
case 48:
#line	289	"asm.y"
{
		yypt[-0].yyv.addr->mode |= AIND;
		yyval.addr = yypt[-0].yyv.addr;
	} break;
case 49:
#line	294	"asm.y"
{
		yypt[-1].yyv.addr->mode |= AIND;
		if(yypt[-1].yyv.addr->val & 3)
			diag("indirect offset must be word size");
		if(yypt[-1].yyv.addr->mode == (AMP|AIND) && ((ulong)yypt[-1].yyv.addr->val > 0xFFFF || (ulong)yypt[-3].yyv.ival > 0xFFFF))
			diag("indirect offset %d(%d(mp)) too large", yypt[-3].yyv.ival, yypt[-1].yyv.addr->val);
		if(yypt[-1].yyv.addr->mode == (AFP|AIND) && ((ulong)yypt[-1].yyv.addr->val > 0xFFFF || (ulong)yypt[-3].yyv.ival > 0xFFFF))
			diag("indirect offset %d(%d(fp)) too large", yypt[-3].yyv.ival, yypt[-1].yyv.addr->val);
		yypt[-1].yyv.addr->off = yypt[-1].yyv.addr->val;
		yypt[-1].yyv.addr->val = yypt[-3].yyv.ival;
		yyval.addr = yypt[-1].yyv.addr;
	} break;
case 51:
#line	310	"asm.y"
{
		yyval.addr = aa(yypt[-3].yyv.ival);
		yyval.addr->mode = AMP;
	} break;
case 52:
#line	315	"asm.y"
{
		yyval.addr = aa(yypt[-3].yyv.ival);
		yyval.addr->mode = AFP;
	} break;
case 54:
#line	323	"asm.y"
{
		yyval.ival = yypt[-0].yyv.sym->value;
	} break;
case 55:
#line	327	"asm.y"
{
		yyval.ival = -yypt[-0].yyv.ival;
	} break;
case 56:
#line	331	"asm.y"
{
		yyval.ival = yypt[-0].yyv.ival;
	} break;
case 57:
#line	335	"asm.y"
{
		yyval.ival = ~yypt[-0].yyv.ival;
	} break;
case 58:
#line	339	"asm.y"
{
		yyval.ival = yypt[-1].yyv.ival;
	} break;
case 60:
#line	346	"asm.y"
{
		yyval.ival = yypt[-2].yyv.ival + yypt[-0].yyv.ival;
	} break;
case 61:
#line	350	"asm.y"
{
		yyval.ival = yypt[-2].yyv.ival - yypt[-0].yyv.ival;
	} break;
case 62:
#line	354	"asm.y"
{
		yyval.ival = yypt[-2].yyv.ival * yypt[-0].yyv.ival;
	} break;
case 63:
#line	358	"asm.y"
{
		yyval.ival = yypt[-2].yyv.ival / yypt[-0].yyv.ival;
	} break;
case 64:
#line	362	"asm.y"
{
		yyval.ival = yypt[-2].yyv.ival % yypt[-0].yyv.ival;
	} break;
case 65:
#line	366	"asm.y"
{
		yyval.ival = yypt[-3].yyv.ival << yypt[-0].yyv.ival;
	} break;
case 66:
#line	370	"asm.y"
{
		yyval.ival = yypt[-3].yyv.ival >> yypt[-0].yyv.ival;
	} break;
case 67:
#line	374	"asm.y"
{
		yyval.ival = yypt[-2].yyv.ival & yypt[-0].yyv.ival;
	} break;
case 68:
#line	378	"asm.y"
{
		yyval.ival = yypt[-2].yyv.ival ^ yypt[-0].yyv.ival;
	} break;
case 69:
#line	382	"asm.y"
{
		yyval.ival = yypt[-2].yyv.ival | yypt[-0].yyv.ival;
	} break;
	}
	goto yystack;  /* stack new state and value */
}
Ejemplo n.º 6
0
/* creates your founder */
void makecharacter()
{
   Creature *newcr=new Creature;
   newcr->align=1;

#ifdef BLIND
   newcr->special[SPECIALWOUND_RIGHTEYE]=1;
   newcr->special[SPECIALWOUND_LEFTEYE]=1;
#endif
#ifdef SPINE
   newcr->special[SPECIALWOUND_UPPERSPINE]=1;
   newcr->special[SPECIALWOUND_LOWERSPINE]=1;
#endif
#ifdef NOFACE
   newcr->special[SPECIALWOUND_TONGUE]=1;
   newcr->special[SPECIALWOUND_RIGHTEYE]=1;
   newcr->special[SPECIALWOUND_LEFTEYE]=1;
   newcr->special[SPECIALWOUND_NOSE]=1;
#endif
#ifdef NOWALK
   newcr->special[SPECIALWOUND_UPPERSPINE]=1;
   newcr->special[SPECIALWOUND_LOWERSPINE]=1;
   newcr->special[SPECIALWOUND_NECK]=1;
   newcr->wound[BODYPART_LEG_RIGHT]=1;
   newcr->wound[BODYPART_LEG_LEFT]=1;
#endif
#ifdef INTERNAL
   newcr->special[SPECIALWOUND_RIGHTLUNG]=1;
   newcr->special[SPECIALWOUND_LEFTLUNG]=1;
   newcr->special[SPECIALWOUND_HEART]=1;
   newcr->special[SPECIALWOUND_LIVER]=1;
   newcr->special[SPECIALWOUND_STOMACH]=1;
   newcr->special[SPECIALWOUND_LEFTKIDNEY]=1;
   newcr->special[SPECIALWOUND_RIGHTKIDNEY]=1;
   newcr->special[SPECIALWOUND_SPLEEN]=1;
#endif

   newcr->set_attribute(ATTRIBUTE_HEART,8);
   newcr->set_attribute(ATTRIBUTE_WISDOM,1);
   newcr->set_attribute(ATTRIBUTE_INTELLIGENCE,3);
   newcr->set_attribute(ATTRIBUTE_AGILITY,5);
   newcr->set_attribute(ATTRIBUTE_STRENGTH,4);
   newcr->set_attribute(ATTRIBUTE_HEALTH,6);
   newcr->set_attribute(ATTRIBUTE_CHARISMA,4);
   for(int sk=0;sk<SKILLNUM;sk++)newcr->set_skill(sk,0);

   char first[3][80];
   char last[80];
   bool male = LCSrandom(2); // whether or not starting gender is male
   char gender = newcr->gender_liberal = newcr->gender_conservative = (male ? GENDER_MALE : GENDER_FEMALE);
   do {
      firstname(first[0], GENDER_NEUTRAL);
      firstname(first[1], GENDER_MALE);
      firstname(first[2], GENDER_FEMALE);
      lastname(last);
   } while(strcmp(first[0],last) == 0 && strcmp(first[1],last) == 0 && strcmp(first[2],last) == 0);

   {
      Armor a(*armortype[getarmortype("ARMOR_CLOTHES")]);
      newcr->give_armor(a,NULL);
   }

   bool choices=true;

   while(true)
   {
      erase();

      set_color(COLOR_WHITE,COLOR_BLACK,1);
      move(4,6);
      addstr("The Founder of the Liberal Crime Squad");

      move(7,2);
      addstr("FIRST NAME: ");
      addstr(first[(int)gender]);
      move(7,30);
      set_color(COLOR_BLACK,COLOR_BLACK,1);
      addstr(" (Press A to have your parents reconsider)");

      move(9,2);
      set_color(COLOR_WHITE,COLOR_BLACK,1);
      addstr("LAST NAME: ");
      addstr(last);
      move(9,30);
      set_color(COLOR_BLACK,COLOR_BLACK,1);
      addstr(" (Press B to be born to a different family)");

      move(11,2);
      set_color(COLOR_WHITE,COLOR_BLACK,1);
      addstr("SEX: ");
      if(newcr->gender_conservative == GENDER_MALE)
      {
         set_color(COLOR_CYAN,COLOR_BLACK,1);
         addstr("Male");
      }
      else if(newcr->gender_conservative == GENDER_FEMALE)
      {
         set_color(COLOR_MAGENTA,COLOR_BLACK,1);
         addstr("Female");
      }
      else
      {
         set_color(COLOR_YELLOW,COLOR_BLACK,1);
         addstr("It's Complicated");
      }
      move(11,30);
      set_color(COLOR_BLACK,COLOR_BLACK,1);
      addstr(" (Press C to change your sex at birth)");

      move(13,2);
      set_color(COLOR_WHITE,COLOR_BLACK,1);
      addstr("HISTORY: ");
      if(choices)
      {
         set_color(COLOR_GREEN,COLOR_BLACK,1);
         addstr("Let Me Choose");
      }
      else
      {
         set_color(COLOR_RED,COLOR_BLACK,1);
         addstr("Let Fate Decide");
      }
      move(13,30);
      set_color(COLOR_BLACK,COLOR_BLACK,1);
      addstr(" (Press D to toggle childhood)");

      if(!multipleCityMode)
      {
         move(15,2);
         set_color(COLOR_WHITE,COLOR_BLACK,1);
         addstr("CITY: ");
         addstr(lcityname);
         move(15,30);
         set_color(COLOR_BLACK,COLOR_BLACK,1);
         addstr(" (Press E to relocate)");
      }

      move(19-multipleCityMode*2,4);
      set_color(COLOR_WHITE,COLOR_BLACK,0);
      addstr("Press any other key when ready to begin...");

      int c=getkey();

      if(c=='a')
      {
         do {
            firstname(first[(int)gender],newcr->gender_conservative);
         } while(strcmp(first[(int)gender],last) == 0);
         continue;
      }
      if(c=='b')
      {
         do {
            lastname(last);
         } while(strcmp(first[0],last) == 0 && strcmp(first[1],last) == 0 && strcmp(first[2],last) == 0);
         continue;
      }
      if(c=='c')
      {
         if((newcr->gender_conservative == GENDER_FEMALE && !male) ||
            (newcr->gender_conservative == GENDER_NEUTRAL && male))
            newcr->gender_conservative = GENDER_MALE;
         else if((newcr->gender_conservative == GENDER_MALE && !male) ||
            (newcr->gender_conservative == GENDER_FEMALE && male))
            newcr->gender_conservative = GENDER_NEUTRAL;
         else
            newcr->gender_conservative = GENDER_FEMALE;

         gender = newcr->gender_liberal = newcr->gender_conservative;
         continue;
      }
      if(c=='d')
      {
         choices = !choices;
         continue;
      }
      if(c=='e' && !multipleCityMode)
      {
         strcpy(lcityname,cityname());
         continue;
      }
      break;
   }

   strcpy(newcr->propername,first[(int)gender]);
   strcat(newcr->propername," ");
   strcat(newcr->propername,last);

   int c;
   bool hasmaps=false;
   bool makelawyer=false;
   bool gaylawyer=false;
   Vehicle * startcar = NULL;
   char recruits = RECRUITS_NONE;
   char base = SITE_RESIDENTIAL_SHELTER;

   for(int q=0;q<10;q++)
   {
      erase();
      set_color(COLOR_WHITE,COLOR_BLACK,1);
      move(0,0);
      addstr("Insight into a Revolution:  My Traumatic Childhood");
      set_color(COLOR_WHITE,COLOR_BLACK,0);

      //A - Thief
      //B - Fighter
      //C - Student
      //D - Generalist/Sleepers
      //E - Recruiter

      char selection = LCSrandom(5);

      switch(q)
      {

/*
        - The anniversary of Hitler's suicide. - SKILL_PISTOL 1 (lol)
        - Indira Gandhi Killed
*/

         case 0:
            move(2,0);addstr("The day I was born in 1984...");

            move(5,0);
            if(choices || selection == 0)
               addstr("A - the Polish priest Popieluszko was kidnapped by government agents.");
            //ATTRIBUTE_AGILITY 2
            // Oct. 19, 1984
            move(7,0);
            if(choices || selection == 1)
               addstr("B - was the 3rd anniversary of the assassination attempt on Ronald Reagan.");
            //ATTRIBUTE_STRENGTH 2
            // Mar. 3, 1984
            move(9,0);
            if(choices || selection == 2)
               addstr("C - the Macintosh was introduced.");
            //ATTRIBUTE_INTELLIGENCE 2
            // Jan. 24, 1984
            move(11,0);
            if(choices || selection == 3)
               addstr("D - the Nobel Peace Prize went to Desmond Tutu for opposition to apartheid.");
            //ATTRIBUTE_HEART 2
            // Oct. 16, 1984
            move(13,0);
            if(choices || selection == 4)
               addstr("E - the Sandanista Front won the elections in Nicaragua.");
            //ATTRIBUTE_CHARISMA 2
            // Sept. 4, 1984
                        //move(14,0);
                        //if(choices || selection == 5)
               //addstr("F - the United Nations condemned Iraq's use of chemical weapons.");
            //ATTRIBUTE_HEALTH 2
                        //March 30, 1984

            move(17,0);
            addstr("The doctor said I was ");
            set_color(COLOR_WHITE,COLOR_BLACK,1);
            if(newcr->gender_conservative == GENDER_MALE)
               addstr("a boy");
            else if(newcr->gender_conservative == GENDER_FEMALE)
               addstr("a girl");
            else
               addstr("an intersex baby");
            set_color(COLOR_WHITE,COLOR_BLACK,0);
            addstr(".");

            move(19,0);
            addstr("My parents ");
            if(newcr->gender_conservative == GENDER_NEUTRAL)
            {
               addstr("insisted otherwise.");
               move(20,0);
               addstr("They ");
            }

            addstr("named me ");
            set_color(COLOR_WHITE,COLOR_BLACK,1);
            addstr(newcr->propername);
            set_color(COLOR_WHITE,COLOR_BLACK,0);
            addstr(".");

            break;

                // My first memory was...
                        // my father burning my back with a cigarette
                // When he was really into the sauce...
                        //
                // XXX: Needs an option to have the founder have been in the Army -- LK
                // XXX: Something I forgot.

         case 1:
            move(2,0);addstr("When I was bad...");
            move(5,0);
            if(choices || selection == 0)
               addstr("A - my parents grounded me and hid my toys, but I knew where they put them."); // Toy box
            //SKILL_SECURITY 1
            //ATTRIBUTE_AGILITY 1
            move(7,0);
            if(choices || selection == 1)
               addstr("B - my father beat me.  I learned to take a punch earlier than most.");
            //SKILL_HANDTOHAND 1
            //ATTRIBUTE_HEALTH 1
            move(9,0);
            if(choices || selection == 2)
               addstr("C - I was sent to my room, where I studied quietly by myself, alone.");
            //SKILL_WRITING 1
            //ATTRIBUTE_INTELLIGENCE 1
            move(11,0);
            if(choices || selection == 3)
               addstr("D - my parents argued with each other about me, but I was never punished.");
            //SKILL_PERSUASION 1
            //ATTRIBUTE_HEART 1
            move(13,0);
            if(choices || selection == 4)
               addstr("E - my father lectured me endlessly, trying to make me think like him.");
            //SKILL_PSYCHOLOGY 1
            //ATTRIBUTE_CHARISMA 1

            /*switch(c)
            {
            case 'e':
               move(17,4);
               addstr("\"The worst has happened. Someone wanted to kill and killed");
               move(18,4);
               addstr("not only the a man, not only a Pole, not only a priest.");
               move(19,4);
               addstr("Someone wanted to kill the hope that it is possible to avoid");
               move(20,4);
               addstr("violence in Polish political life.\"");
               move(21,8);
               addstr("- Solidarity Leader Lech Walesa");
               break;
            default:
               break;
            }*/
            break;
         case 2:
            move(2,0);addstr("In elementary school...");
            move(5,0);
            if(choices || selection == 0)
               addstr("A - I was mischievous, and always up to something.");
            //SKILL_DISGUISE 1
            //ATTRIBUTE_AGILITY 1
            move(7,0);
            if(choices || selection == 1)
               addstr("B - I had a lot of repressed anger.  I hurt animals.");
            //SKILL_PSYCHOLOGY 1
            //ATTRIBUTE_STRENGTH 1
            //ATTRIBUTE_AGILITY 1
            //ATTRIBUTE_HEART -1 <--- !
            move(9,0);
            if(choices || selection == 2)
               addstr("C - I was at the head of the class, and I worked very hard.");
            //ATTRIBUTE_INTELLIGENCE 1
            //SKILL_WRITING 1
            move(11,0);
            if(choices || selection == 3)
               addstr("D - I was unruly and often fought with the other children.");
            //SKILL_HANDTOHAND 1
            //ATTRIBUTE_STRENGTH 1
            move(13,0);
            if(choices || selection == 4)
               addstr("E - I was the class clown.  I even had some friends.");
            //SKILL_PERSUASION 1
            //ATTRIBUTE_CHARISMA 1
            break;
         case 3:
            move(2,0);addstr("When I turned 10...");
            move(5,0);
            if(choices || selection == 0)
               addstr("A - my parents divorced.  Whenever I talked, they argued, so I stayed quiet.");
            //SKILL_STEALTH 1
            move(7,0);
            if(choices || selection == 1)
               addstr("B - my parents divorced.  Violently.");
            //SKILL_HANDTOHAND 1
            move(9,0);
            if(choices || selection == 2)
               addstr("C - my parents divorced.  Acrimoniously.  I once tripped over the paperwork!");
            //SKILL_LAW 1
            move(11,0);
            if(choices || selection == 3)
               addstr("D - my parents divorced.  Mom slept with the divorce lawyer.");
            //SKILL_SEDUCTION 1
            move(13,0);
            if(choices || selection == 4)
               addstr("E - my parents divorced.  It still hurts to read my old diary.");
            //SKILL_WRITING 1
            break;
         case 4:
            move(2,0);addstr("In junior high school...");
            move(5,0);
            if(choices || selection == 0)
               addstr("A - I was into chemistry.  I wanted to know what made the world tick.");
            //SKILL_SCIENCE 2
            //ATTRIBUTE_INTELLIGENCE 2
            move(7,0);
            if(choices || selection == 1)
               addstr("B - I played guitar in a grunge band.  We sucked, but so did life.");
            //SKILL_MUSIC 2
            //ATTRIBUTE_CHARISMA 2
            move(9,0);
            if(choices || selection == 2)
               addstr("C - I drew things, a lot.  I was drawing a world better than this.");
            //SKILL_ART 2
            //ATTRIBUTE_HEART 2
            move(11,0);
            if(choices || selection == 3)
               addstr("D - I played violent video games at home.  I was a total outcast.");
            //SKILL_COMPUTERS 2
            //ATTRIBUTE_AGILITY 2
            move(13,0);
            if(choices || selection == 4)
               addstr("E - I was obsessed with swords, and started lifting weights.");
            //SKILL_SWORD 2
            //ATTRIBUTE_STRENGTH 2
            break;
         case 5:
            move(2,0);addstr("Things were getting really bad...");
            move(5,0);
            if(choices || selection == 0)
               addstr("A - when I stole my first car.  I got a few blocks before I totaled it.");
            //SKILL_DRIVING 1
            //SKILL_SECURITY 1
            move(7,0);
            if(choices || selection == 1)
               addstr("B - and I went to live with my dad.  He had been in Nam and he still drank.");
            //SKILL_SHOTGUN 1
            //SKILL_RIFLE 1
            //SKILL_PSYCHOLOGY 1
            move(9,0);
            if(choices || selection == 2)
               addstr("C - and I went completely goth.  I had no friends and made costumes by myself.");
            //SKILL_TAILORING 2
            move(11,0);
            if(choices || selection == 3)
               addstr("D - when I was sent to religious counseling, just stressing me out more.");
            //SKILL_RELIGION 1
            //SKILL_PSYCHOLOGY 1
            move(13,0);
            if(choices || selection == 4)
               addstr("E - and I tried being a teacher's assistant.  It just made me a target.");
            //SKILL_TEACHING 2
            break;
         case 6:
            move(2,0);addstr("Well, I knew it had reached a crescendo when...");
            move(5,0);
            if(choices || selection == 0)
               addstr("A - I stole a cop car when I was only 14.  I went to juvie for 6 months.");
            //SKILL_DRIVING 1
            //SKILL_SECURITY 1
            //ATTRIBUTE_INTELLIGENCE 1
            move(7,0);
            if(choices || selection == 1)
               addstr("B - my step mom shot her ex-husband, my dad, with a shotgun.  She got off.");//XXX: Sounds... Sexual...
            //SKILL_SHOTGUN 2
            //ATTRIBUTE_AGILITY 1
            move(9,0);
            if(choices || selection == 2)
               addstr("C - I tried wrestling for a quarter, desperate to fit in.");
            //ATTRIBUTE_STRENGTH 1
            //SKILL_HANDTOHAND 2
            move(11,0);
            if(choices || selection == 3)
               addstr("D - I got caught making out, and now I needed to be 'cured' of homosexuality.");
            //SKILL_SEDUCTION 1
            //SKILL_RELIGION 1
            //ATTRIBUTE_HEART 1
            move(13,0);
            if(choices || selection == 4)
               addstr("E - I resorted to controlling people.  Had my own clique of outcasts.");
            //SKILL_PERSUASION 2
            //ATTRIBUTE_CHARISMA 1
            break;
         case 7:
            move(2,0);addstr("I was only 15 when I ran away, and...");
            move(5,0);
            if(choices || selection == 0)
               addstr("A - I started robbing houses:  rich people only.  I was fed up with their crap.");
            //SKILL_SECURITY 1
            //SKILL_STEALTH 1
            //ATTRIBUTE_AGILITY 1
            move(7,0);
            if(choices || selection == 1)
               addstr("B - I hung out with thugs and beat the shit out of people.");
            //ATTRIBUTE_STRENGTH 1
            //SKILL_HANDTOHAND 2
            move(9,0);
            if(choices || selection == 2)
               addstr("C - I got a horrible job working fast food, smiling as people fed the man.");
            //ATTRIBUTE_CHARISMA 1
            //SKILL_BUSINESS 2
            move(11,0);
            if(choices || selection == 3)
               addstr("D - I let people pay me for sex.  I needed the money to survive.");
            //ATTRIBUTE_HEART -1
            //ATTRIBUTE_CHARISMA 2
            //SKILL_SEDUCTION 2
            move(13,0);
            if(choices || selection == 4)
               addstr("E - I volunteered for a left-wing candidate. It wasn't *real*, though, you know?");
            //ATTRIBUTE_INTELLIGENCE 1
            //SKILL_LAW 1
            //SKILL_PERSUASION 1
            break;
         case 8:
            move(2,0);addstr("Life went on.  On my 18th birthday...");
            move(5,0);
            if(choices || selection == 0)
               addstr("A - I got my hands on a sports car. The owner must have been pissed.");
            move(7,0);
            if(choices || selection == 1)
               addstr("B - I bought myself an assault rifle.");
            move(9,0);
            if(choices || selection == 2)
               addstr("C - I celebrated.  I'd saved a thousand bucks!");
            move(11,0);
            if(choices || selection == 3)
               addstr("D - I went to a party and met a cool law student.  We've been dating since.");//XXX: No Seduction?
            move(13,0);
            if(choices || selection == 4)
               addstr("E - I managed to acquire secret maps of several major buildings downtown.");
            break;
         case 9:
            move(2,0);addstr("For the past few years, I've been...");
            move(5,0);
            if(choices || selection == 0)
               addstr("A - stealing from Corporations.  I know they're still keeping more secrets.");
            //ATTRIBUTE_INTELLIGENCE 2
            //ATTRIBUTE_AGILITY 2
            //SKILL_SECURITY 2
            //SKILL_STEALTH 2
            // +Downtown apartment
            // +$500 (one month rent)
            move(7,0);
            if(choices || selection == 1)
               addstr("B - a violent criminal.  Nothing can change me, or stand in my way.");
            //SKILL_RIFLE 2
            //SKILL_PISTOL 2
            //SKILL_STREETSENSE 2
            //ATTRIBUTE_AGILITY 2
            //ATTRIBUTE_HEALTH 2
            //ATTRIBUTE_STRENGTH 2
            // +Crack house (with stockpiled rations)
            // +A crew (four gang members with knives and pistols)
            move(9,0);
            if(choices || selection == 2)
               addstr("C - taking college courses.  I can see how much the country needs help.");
            //SKILL_SCIENCE 2
            //SKILL_COMPUTERS 2
            //SKILL_WRITING 2
            //SKILL_TEACHING 2
            //SKILL_BUSINESS 1
            //SKILL_LAW 1
            //ATTRIBUTE_INTELLIGENCE 4
            // +University apartment
            // +$200 (one month rent)
            move(11,0);
            if(choices || selection == 3)
               addstr("D - surviving alone, just like anyone.  But we can't go on like this.");
            //SKILL_FIRSTAID 2
            //SKILL_STREETSENSE 2
            //ATTRIBUTE_INTELLIGENCE 1
            //ATTRIBUTE_AGILITY 1
            //ATTRIBUTE_HEALTH 2
            // +Homeless shelter
            // +1 all stats (except Wisdom)
            move(13,0);
            if(choices || selection == 4)
               addstr("E - writing my manifesto and refining my image.  I'm ready to lead.");
            //ATTRIBUTE_CHARISMA 2
            //ATTRIBUTE_INTELLIGENCE 2
            //SKILL_LAW 1
            //SKILL_PERSUASION 2
            //SKILL_WRITING 1
            // +Industrial apartment
            // +$100 (one month rent)
            // +50 juice
            move(17,0);
            addstr("I live in ");
            if(!multipleCityMode) addstr(lcityname);
            else addstr("Seattle, WA");
            addstr(", and it's about to experience real change.");
            break;
      }

      do
      {
         c=getkey();
         if(!choices) c='a'+selection;
      } while(c<'a'||c>'e');

      switch(q)
      {
         case 0:
            // Oct. 19, 1984
            if(c=='a')
            {
               newcr->adjust_attribute(ATTRIBUTE_AGILITY,+2);
               newcr->birthday_month = 10;
               newcr->birthday_day = 19;
            }
            // Mar. 3, 1984
            if(c=='b')
            {
               newcr->adjust_attribute(ATTRIBUTE_STRENGTH,+2);
               newcr->birthday_month = 3;
               newcr->birthday_day = 3;
            }
            // Jan. 24, 1984
            if(c=='c')
            {
               newcr->adjust_attribute(ATTRIBUTE_INTELLIGENCE,+2);
               newcr->birthday_month = 1;
               newcr->birthday_day = 24;
            }
            // Oct. 16, 1984
            if(c=='d')
            {
               newcr->adjust_attribute(ATTRIBUTE_HEART,+2);
               newcr->birthday_month = 10;
               newcr->birthday_day = 16;
            }
            // Sep. 4, 1984
            if(c=='e')
            {
               newcr->adjust_attribute(ATTRIBUTE_CHARISMA,+2);
               newcr->birthday_month = 9;
               newcr->birthday_day = 4;
            }
            newcr->age = year - 1984;
            // Don't count this year in founder's age if starting before birthday
            if(month < newcr->birthday_month ||
               (month==newcr->birthday_month && day<newcr->birthday_day))
            {
               newcr->age--;
            }
            break;
         case 1:
            if(c=='a')
            {
               newcr->set_skill(SKILL_SECURITY,newcr->get_skill(SKILL_SECURITY)+(1));
               newcr->adjust_attribute(ATTRIBUTE_AGILITY,+1);
            }
            if(c=='b')
            {
               newcr->set_skill(SKILL_HANDTOHAND,newcr->get_skill(SKILL_HANDTOHAND)+(1));
               newcr->adjust_attribute(ATTRIBUTE_HEALTH,+1);
            }
            if(c=='c')
            {
               newcr->adjust_attribute(ATTRIBUTE_INTELLIGENCE,+1);
               newcr->set_skill(SKILL_WRITING,newcr->get_skill(SKILL_WRITING)+(1));
            }
            if(c=='d')
            {
               newcr->set_skill(SKILL_PERSUASION,newcr->get_skill(SKILL_PERSUASION)+(1));
               newcr->adjust_attribute(ATTRIBUTE_HEART,+1);
            }
            if(c=='e')
            {
               newcr->set_skill(SKILL_PSYCHOLOGY,newcr->get_skill(SKILL_PSYCHOLOGY)+(1));
               newcr->adjust_attribute(ATTRIBUTE_CHARISMA,+1);
            }
            break;
         case 2:
            if(c=='a')
            {
               newcr->set_skill(SKILL_DISGUISE,newcr->get_skill(SKILL_DISGUISE)+(1));
               newcr->adjust_attribute(ATTRIBUTE_AGILITY,+1);
            }
            if(c=='b')
            {
               newcr->set_skill(SKILL_PSYCHOLOGY,newcr->get_skill(SKILL_PSYCHOLOGY)+(1));
               newcr->adjust_attribute(ATTRIBUTE_AGILITY,+1);
               newcr->adjust_attribute(ATTRIBUTE_HEART,-1);
               newcr->adjust_attribute(ATTRIBUTE_STRENGTH,+1);
            }
            if(c=='c')
            {
               newcr->adjust_attribute(ATTRIBUTE_INTELLIGENCE,+1);
               newcr->set_skill(SKILL_WRITING,newcr->get_skill(SKILL_WRITING)+(1));
            }
            if(c=='d')
            {
               newcr->adjust_attribute(ATTRIBUTE_STRENGTH,+1);
               newcr->set_skill(SKILL_HANDTOHAND,newcr->get_skill(SKILL_HANDTOHAND)+(1));
            }
            if(c=='e')
            {
               newcr->set_skill(SKILL_PERSUASION,newcr->get_skill(SKILL_PERSUASION)+(1));
               newcr->adjust_attribute(ATTRIBUTE_CHARISMA,+1);
            }
            break;
         case 3:
            if(c=='a')
            {
               newcr->set_skill(SKILL_STEALTH,newcr->get_skill(SKILL_STEALTH)+(1));
            }
            if(c=='b')
            {
               newcr->set_skill(SKILL_HANDTOHAND,newcr->get_skill(SKILL_HANDTOHAND)+(1));
            }
            if(c=='c')
            {
               newcr->set_skill(SKILL_LAW,newcr->get_skill(SKILL_LAW)+(1));
            }
            if(c=='d')
            {
               newcr->set_skill(SKILL_SEDUCTION,newcr->get_skill(SKILL_SEDUCTION)+(1));
            }
            if(c=='e')
            {
               newcr->set_skill(SKILL_WRITING,newcr->get_skill(SKILL_WRITING)+1);
            }
            break;
         case 4:
            if(c=='a')
            {
               newcr->set_skill(SKILL_SCIENCE,newcr->get_skill(SKILL_SCIENCE)+(2));
               newcr->adjust_attribute(ATTRIBUTE_INTELLIGENCE,+2);
            }
            if(c=='b')
            {
               newcr->set_skill(SKILL_MUSIC,newcr->get_skill(SKILL_MUSIC)+(2));
               newcr->adjust_attribute(ATTRIBUTE_CHARISMA,+2);
            }
            if(c=='c')
            {
               newcr->set_skill(SKILL_ART,newcr->get_skill(SKILL_ART)+(2));
               newcr->adjust_attribute(ATTRIBUTE_HEART,+2);
            }
            if(c=='d')
            {
               newcr->set_skill(SKILL_COMPUTERS,newcr->get_skill(SKILL_COMPUTERS)+(2));
               newcr->adjust_attribute(ATTRIBUTE_AGILITY,+2);
            }
            if(c=='e')
            {
               newcr->adjust_attribute(ATTRIBUTE_STRENGTH,+2);
               newcr->set_skill(SKILL_SWORD,newcr->get_skill(SKILL_SWORD)+(2));
            }
            break;
         case 5:
            if(c=='a')
            {
               newcr->set_skill(SKILL_DRIVING,newcr->get_skill(SKILL_DRIVING)+(1));
               newcr->set_skill(SKILL_SECURITY,newcr->get_skill(SKILL_SECURITY)+(1));
            }
            if(c=='b')
            {
               newcr->set_skill(SKILL_SHOTGUN,newcr->get_skill(SKILL_SHOTGUN)+(1));
               newcr->set_skill(SKILL_RIFLE,newcr->get_skill(SKILL_RIFLE)+(1));
               newcr->set_skill(SKILL_PSYCHOLOGY,newcr->get_skill(SKILL_PSYCHOLOGY)+(1));
            }
            if(c=='c')
            {
               newcr->set_skill(SKILL_TAILORING,newcr->get_skill(SKILL_TAILORING)+(2));
            }
            if(c=='d')
            {
               newcr->set_skill(SKILL_RELIGION,newcr->get_skill(SKILL_RELIGION)+(1));
               newcr->set_skill(SKILL_PSYCHOLOGY,newcr->get_skill(SKILL_PSYCHOLOGY)+(1));
            }
            if(c=='e')
            {
               newcr->set_skill(SKILL_TEACHING,newcr->get_skill(SKILL_TEACHING)+(2));
            }
            break;
         case 6:
            if(c=='a')
            {
               newcr->set_skill(SKILL_DRIVING,newcr->get_skill(SKILL_DRIVING)+(1));
               newcr->set_skill(SKILL_SECURITY,newcr->get_skill(SKILL_SECURITY)+(1));
               newcr->adjust_attribute(ATTRIBUTE_INTELLIGENCE,+1);
            }
            if(c=='b')
            {
               newcr->set_skill(SKILL_SHOTGUN,newcr->get_skill(SKILL_SHOTGUN)+(2));
               newcr->adjust_attribute(ATTRIBUTE_AGILITY,+1);
            }
            if(c=='c')
            {
               newcr->adjust_attribute(ATTRIBUTE_STRENGTH,+1);
               newcr->set_skill(SKILL_HANDTOHAND,newcr->get_skill(SKILL_HANDTOHAND)+(2));
            }
            if(c=='d')
            {
               newcr->set_skill(SKILL_SEDUCTION,newcr->get_skill(SKILL_SEDUCTION)+(1));
               newcr->set_skill(SKILL_RELIGION,newcr->get_skill(SKILL_RELIGION)+(1));
               newcr->adjust_attribute(ATTRIBUTE_HEART,+1);
               gaylawyer=true;
            }
            if(c=='e')
            {
               newcr->set_skill(SKILL_PERSUASION,newcr->get_skill(SKILL_PERSUASION)+(2));
               newcr->adjust_attribute(ATTRIBUTE_CHARISMA,+1);
            }
            break;
         case 7:
            if(c=='a')
            {
               newcr->set_skill(SKILL_SECURITY,newcr->get_skill(SKILL_SECURITY)+(1));
               newcr->set_skill(SKILL_STEALTH,newcr->get_skill(SKILL_STEALTH)+(1));
               newcr->adjust_attribute(ATTRIBUTE_AGILITY,+1);
            }
            if(c=='b')
            {
               newcr->adjust_attribute(ATTRIBUTE_STRENGTH,+1);
               newcr->set_skill(SKILL_HANDTOHAND,newcr->get_skill(SKILL_HANDTOHAND)+(2));
            }
            if(c=='c')
            {
               newcr->adjust_attribute(ATTRIBUTE_CHARISMA,+1);
               newcr->set_skill(SKILL_BUSINESS,newcr->get_skill(SKILL_BUSINESS)+(2));
            }
            if(c=='d')
            {
               newcr->adjust_attribute(ATTRIBUTE_HEART,-1);
               newcr->adjust_attribute(ATTRIBUTE_CHARISMA,+2);
               newcr->set_skill(SKILL_SEDUCTION,newcr->get_skill(SKILL_SEDUCTION)+(2));
            }
            if(c=='e')
            {
               newcr->adjust_attribute(ATTRIBUTE_INTELLIGENCE,+1);
               newcr->set_skill(SKILL_LAW,newcr->get_skill(SKILL_LAW)+(1));
               newcr->set_skill(SKILL_PERSUASION,newcr->get_skill(SKILL_PERSUASION)+(1));
            }
            break;
         case 8:
            if(c=='a')
            {
               startcar = new Vehicle(*vehicletype[getvehicletype("SPORTSCAR")]);
               // Add heat to the starting vehicle because it is stolen.
               // This is so that you can't immediately sell it at full price.
               startcar->add_heat(10);
               vehicle.push_back(startcar);
               newcr->pref_carid = startcar->id();
            }
            if(c=='b')
            {
               Weapon neww(*weapontype[getweapontype("WEAPON_AUTORIFLE_AK47")]);
               Clip newc(*cliptype[getcliptype("CLIP_ASSAULT")],9);
               newcr->give_weapon(neww,NULL);
               newcr->take_clips(newc,9);
            }
            if(c=='c')
            {
               ledger.force_funds(1000);
            }
            if(c=='d')
            {
               makelawyer=true;
            }
            if(c=='e')
            {
               hasmaps=true;
            }
            break;
         case 9:
            if(c=='a')
            {
               newcr->adjust_attribute(ATTRIBUTE_INTELLIGENCE,+2);
               newcr->adjust_attribute(ATTRIBUTE_AGILITY,+2);
               newcr->set_skill(SKILL_SECURITY,newcr->get_skill(SKILL_SECURITY)+(2));
               newcr->set_skill(SKILL_STEALTH,newcr->get_skill(SKILL_STEALTH)+(2));
               newcr->type = CREATURE_THIEF;
               newcr->type_idname = "CREATURE_THIEF";
               base = SITE_RESIDENTIAL_APARTMENT_UPSCALE;
               ledger.force_funds(ledger.get_funds()+500);

               Armor newa(*armortype[getarmortype("ARMOR_BLACKCLOTHES")]);
               newcr->give_armor(newa,NULL);
            }
            if(c=='b')
            {
               newcr->set_skill(SKILL_RIFLE,newcr->get_skill(SKILL_RIFLE)+(2));
               newcr->set_skill(SKILL_PISTOL,newcr->get_skill(SKILL_PISTOL)+(2));
               newcr->set_skill(SKILL_STREETSENSE,newcr->get_skill(SKILL_STREETSENSE)+(2));
               newcr->adjust_attribute(ATTRIBUTE_AGILITY,+2);
               newcr->adjust_attribute(ATTRIBUTE_HEALTH,+2);
               newcr->adjust_attribute(ATTRIBUTE_STRENGTH,+2);
               newcr->type = CREATURE_GANGMEMBER;
               newcr->type_idname = "CREATURE_GANGMEMBER";
               base = SITE_BUSINESS_CRACKHOUSE;
               recruits = RECRUITS_GANG;
            }
            if(c=='c')
            {
               newcr->adjust_attribute(ATTRIBUTE_INTELLIGENCE,+4);
               newcr->set_skill(SKILL_SCIENCE,newcr->get_skill(SKILL_SCIENCE)+(2));
               newcr->set_skill(SKILL_COMPUTERS,newcr->get_skill(SKILL_COMPUTERS)+(2));
               newcr->set_skill(SKILL_WRITING,newcr->get_skill(SKILL_WRITING)+(2));
               newcr->set_skill(SKILL_TEACHING,newcr->get_skill(SKILL_TEACHING)+(2));
               newcr->set_skill(SKILL_BUSINESS,newcr->get_skill(SKILL_BUSINESS)+(1));
               newcr->set_skill(SKILL_LAW,newcr->get_skill(SKILL_LAW)+(1));
               newcr->type = CREATURE_COLLEGESTUDENT;
               newcr->type_idname = "CREATURE_COLLEGESTUDENT";
               base = SITE_RESIDENTIAL_APARTMENT;
               ledger.force_funds(ledger.get_funds()+200);
            }
            if(c=='d')
            {
               newcr->adjust_attribute(ATTRIBUTE_INTELLIGENCE,+1);
               newcr->adjust_attribute(ATTRIBUTE_AGILITY,+1);
               newcr->adjust_attribute(ATTRIBUTE_HEALTH,+2);
               newcr->set_skill(SKILL_FIRSTAID,newcr->get_skill(SKILL_FIRSTAID)+(2));
               newcr->set_skill(SKILL_STREETSENSE,newcr->get_skill(SKILL_STREETSENSE)+(2));
               newcr->type = CREATURE_HSDROPOUT;
               newcr->type_idname = "CREATURE_HSDROPOUT";
               base = SITE_RESIDENTIAL_SHELTER;

               newcr->adjust_attribute(ATTRIBUTE_HEART,+1);
               newcr->adjust_attribute(ATTRIBUTE_INTELLIGENCE,+1);
               newcr->adjust_attribute(ATTRIBUTE_AGILITY,+1);
               newcr->adjust_attribute(ATTRIBUTE_STRENGTH,+1);
               newcr->adjust_attribute(ATTRIBUTE_HEALTH,+1);
               newcr->adjust_attribute(ATTRIBUTE_CHARISMA,+1);
            }
            if(c=='e')
            {
               newcr->adjust_attribute(ATTRIBUTE_CHARISMA,+2);
               newcr->adjust_attribute(ATTRIBUTE_INTELLIGENCE,+2);
               newcr->set_skill(SKILL_LAW,newcr->get_skill(SKILL_LAW)+(1));
               newcr->set_skill(SKILL_WRITING,newcr->get_skill(SKILL_WRITING)+(1));
               newcr->set_skill(SKILL_PERSUASION,newcr->get_skill(SKILL_PERSUASION)+(2));
               newcr->type = CREATURE_POLITICALACTIVIST;
               newcr->type_idname = "CREATURE_POLITICALACTIVIST";
               base = SITE_RESIDENTIAL_TENEMENT;
               ledger.force_funds(ledger.get_funds()+50);
               newcr->juice+=50;
            }
            break;
      }
   }

   erase();
   set_color(COLOR_WHITE,COLOR_BLACK,1);
   move(2,2);
   addstr("A NEW CONSERVATIVE ERA", gamelog);
   gamelog.newline();

   set_color(COLOR_WHITE,COLOR_BLACK,0);
   move(4,2);
   addstr("The Year is ", gamelog);
   addstr(year, gamelog);
   addstr(".", gamelog);
   move(6,2);
   gamelog.newline();
   addstr("Conservative President ", gamelog);
   char president[80];
   generate_name(president,GENDER_WHITEMALEPATRIARCH);
   addstr(president, gamelog);
   addstr(" ends his second term with approval", gamelog);
   move(7,2);
   gamelog.newline();
   addstr("ratings in the high 70s, and is succeeded by hardcore Arch-Conservative", gamelog);
   move(8,2);
   gamelog.newline();
   addstr(execname[EXEC_PRESIDENT], gamelog);
   addstr(".", gamelog);
   gamelog.nextMessage();

   move(10,2);
   addstr("With Conservatives sweeping into power in the House of Representatives", gamelog);
   move(11,2);
   gamelog.newline();
   addstr("and Senate, and a Conservative majority in the Supreme Court of the", gamelog);
   move(12,2);
   gamelog.newline();
   addstr("United States, commentators are hailing it as the beginning of a new", gamelog);
   move(13,2);
   gamelog.newline();
   addstr("Conservative era.", gamelog);
   gamelog.nextMessage();

   move(15,2);
   set_color(COLOR_RED,COLOR_BLACK,1);
   addstr("President ", gamelog);
   addstr(execname[EXEC_PRESIDENT], gamelog);
   addstr(" has asked the new Congress to move quickly", gamelog);
   move(16,2);
   gamelog.newline();
   addstr("to rubber stamp his radical Arch-Conservative agenda. ", gamelog);
   set_color(COLOR_WHITE,COLOR_BLACK,0);
   addstr("The left seems", gamelog);
   gamelog.newline();
   move(17,2);
   addstr("powerless to stop this imminent trampling of Liberal Sanity and Justice.", gamelog);
   gamelog.nextMessage();

   move(19,2);
   addstr("In this dark time, the Liberal Crime Squad is born...", gamelog);
   gamelog.nextMessage();

   getkey();

   erase();
   set_color(COLOR_WHITE,COLOR_BLACK,1);
   move(0,0);
   addstr("What is your name to the People?");
   set_color(COLOR_WHITE,COLOR_BLACK,0);
   move(1,0);
   addstr("Press enter to be known by your real name instead.");

   enter_name(2,0,newcr->name,CREATURE_NAMELEN,newcr->propername);

   pool.push_back(newcr);

   make_world(hasmaps);

   squadst *newsq=new squadst;
   newsq->id=0;cursquadid++;
   newsq->squad[0]=newcr;
   newcr->squadid=0;
   strcpy(newsq->name,"The Liberal Crime Squad");
   for(int l=0;l<len(location);l++)
   {
      if(location[l]->type==base)
      {
         newcr->base=l;
         newcr->location=l;
         if(startcar) startcar->set_location(l);
         switch(base)
         {
         case SITE_RESIDENTIAL_APARTMENT_UPSCALE:location[l]->renting=500;break;
         case SITE_RESIDENTIAL_APARTMENT:location[l]->renting=200;break;
         case SITE_RESIDENTIAL_TENEMENT:location[l]->renting=100;break;
         case SITE_BUSINESS_CRACKHOUSE:
            location[l]->renting=RENTING_PERMANENT;
            location[l]->compound_stores+=100;
            break;
         }
         location[l]->newrental=1;

         switch(recruits)
         {
         case RECRUITS_GANG:
            for(int i=0;i<4;i++)
            {
               Creature* recruit = new Creature;
               makecreature(*recruit,CREATURE_GANGMEMBER);
               if(recruit->get_weapon().get_itemtypename() == "WEAPON_AUTORIFLE_AK47" ||
                  recruit->get_weapon().get_itemtypename() == "WEAPON_SMG_MP5" ||
                 !recruit->is_armed())
               {
                  Weapon w(*weapontype[getweapontype("WEAPON_SEMIPISTOL_9MM")]);
                  recruit->give_weapon(w,NULL);
                  Clip c(*cliptype[getcliptype("CLIP_9")],4);
                  recruit->take_clips(c,4);
                  recruit->reload(false);
               }

               recruit->align=ALIGN_LIBERAL;
               recruit->set_attribute(ATTRIBUTE_HEART,
                                      recruit->get_attribute(ATTRIBUTE_HEART,false)+
                                      recruit->get_attribute(ATTRIBUTE_WISDOM,false)/2);
               recruit->set_attribute(ATTRIBUTE_WISDOM,
                                      recruit->get_attribute(ATTRIBUTE_WISDOM,false)/2);

               recruit->namecreature();
               strcpy(recruit->name,recruit->propername);

               recruit->location=l;
               recruit->base=l;

               recruit->hireid=newcr->id;

               newsq->squad[i+1]=recruit;
               recruit->squadid=newsq->id;
               pool.push_back(recruit);
            }
            break;
         }

         #ifdef GIVEBLOODYARMOR
         Armor *newa= new Armor(*armortype[getarmortype("ARMOR_CLOTHES")]);
         newa->set_bloody(true);
         location[l]->loot.push_back(newi);
         #endif

         #ifdef HIGHFUNDS
         ledger.force_funds(100000);
         #endif

         break;
      }
   }
   //newcr->juice=0;
   squad.push_back(newsq);
   activesquad=newsq;

   if(makelawyer)
   {
      Creature* lawyer=new Creature;
      makecreature(*lawyer,CREATURE_LAWYER);
      // Make sure lawyer is of the appropriate gender for dating the main character;
      // opposite sex by default, same sex if the option was chosen that mentions
      // homosexuality
      if(gaylawyer)
      {
         lawyer->gender_conservative=lawyer->gender_liberal=newcr->gender_conservative;

         // neutral founder gets neutral partner
      }
      else
      {
         if(newcr->gender_conservative==GENDER_MALE)
            lawyer->gender_liberal=lawyer->gender_conservative=GENDER_FEMALE;

         if(newcr->gender_conservative==GENDER_FEMALE)
            lawyer->gender_liberal=lawyer->gender_conservative=GENDER_MALE;

         // neutral founder gets random partner
      }

      // Ensure the lawyer has good heart/wisdom stats
      if(lawyer->get_attribute(ATTRIBUTE_HEART,false)<newcr->get_attribute(ATTRIBUTE_HEART,false)-2)
         lawyer->adjust_attribute(ATTRIBUTE_HEART,-2);

      lawyer->set_attribute(ATTRIBUTE_WISDOM,1);

      lawyer->namecreature();
      lawyer->flag|=CREATUREFLAG_SLEEPER;
      lawyer->flag|=CREATUREFLAG_LOVESLAVE;
      lawyer->align=ALIGN_LIBERAL;
      lawyer->infiltration=0.3f;
      lawyer->age=28;

      location[lawyer->worklocation]->mapped=1;
      lawyer->hireid=newcr->id;
      pool.push_back(lawyer);
      lawyer->location=lawyer->base=lawyer->worklocation;
   }

   uniqueCreatures.initialize();
}