@@ -445,86 +445,71 @@ Converting to single-byte not necessary anymore, as UI uses custom font render w
445
445
*/
446
446
int Con_UtfProcessChar ( int in )
447
447
{
448
- if ( UI_IsXashFWGS () )
448
+ static int m = -1 , k = 0 ; // multibyte state
449
+ static int uc = 0 ; // unicode char
450
+
451
+ if ( !in )
449
452
{
450
- static int m = -1 , k = 0 ; // multibyte state
451
- static int uc = 0 ; // unicode char
453
+ m = -1 ;
454
+ k = 0 ;
455
+ uc = 0 ;
456
+ return 0 ;
457
+ }
452
458
453
- if ( !in )
459
+ // Get character length
460
+ if (m == -1 )
461
+ {
462
+ uc = 0 ;
463
+ if ( in >= 0xF8 )
454
464
{
455
- m = -1 ;
456
- k = 0 ;
457
- uc = 0 ;
458
465
return 0 ;
459
466
}
460
-
461
- // Get character length
462
- if (m == -1 )
467
+ else if ( in >= 0xF0 )
463
468
{
464
- uc = 0 ;
465
- if ( in >= 0xF8 )
466
- {
467
- return 0 ;
468
- }
469
- else if ( in >= 0xF0 )
470
- {
471
- uc = in & 0x07 ;
472
- m = 3 ;
473
- }
474
- else if ( in >= 0xE0 )
475
- {
476
- uc = in & 0x0F ;
477
- m = 2 ;
478
- }
479
- else if ( in >= 0xC0 )
480
- {
481
- uc = in & 0x1F ;
482
- m = 1 ;
483
- }
484
- else if ( in <= 0x7F )
485
- {
486
- return in; // ascii
487
- }
488
- // return 0 if we need more chars to decode one
489
- k = 0 ;
490
- return 0 ;
469
+ uc = in & 0x07 ;
470
+ m = 3 ;
491
471
}
492
- // get more chars
493
- else if ( k <= m )
472
+ else if ( in >= 0xE0 )
494
473
{
495
- uc <<= 6 ;
496
- uc += in & 0x3F ;
497
- k++;
474
+ uc = in & 0x0F ;
475
+ m = 2 ;
498
476
}
499
- if ( in > 0xBF || m < 0 )
477
+ else if ( in >= 0xC0 )
500
478
{
501
- m = - 1 ;
502
- return 0 ;
479
+ uc = in & 0x1F ;
480
+ m = 1 ;
503
481
}
504
- if ( k == m )
482
+ else if ( in <= 0x7F )
505
483
{
506
- k = m = -1 ;
507
-
508
- return uc;
509
-
510
- // not implemented yet
511
- // return '?';
484
+ return in; // ascii
512
485
}
486
+ // return 0 if we need more chars to decode one
487
+ k = 0 ;
513
488
return 0 ;
514
489
}
515
- else
490
+ // get more chars
491
+ else if ( k <= m )
516
492
{
517
- if ( in >= 0x80 && in <= 0xBF )
518
- {
519
- return table_cp1251[in - 0x80 ];
520
- }
521
- else if ( in >= 0xC0 && in <= 0xFF )
522
- {
523
- return in - 0xC0 + 0x410 ;
524
- }
493
+ uc <<= 6 ;
494
+ uc += in & 0x3F ;
495
+ k++;
496
+ }
497
+ if ( in > 0xBF || m < 0 )
498
+ {
499
+ m = -1 ;
500
+ return 0 ;
501
+ }
502
+
503
+ if ( k == m )
504
+ {
505
+ k = m = -1 ;
525
506
526
- return in;
507
+ return uc;
508
+
509
+ // not implemented yet
510
+ // return '?';
527
511
}
512
+ return 0 ;
528
513
}
529
514
530
515
/*
@@ -637,42 +622,3 @@ void Com_EscapeCommand( char *newCommand, const char *oldCommand, int len )
637
622
638
623
*newCommand++ = 0 ;
639
624
}
640
-
641
- /*
642
- ================
643
- Sys_DoubleTime
644
- ================
645
- */
646
- double Sys_DoubleTime ( void )
647
- {
648
- if ( UI_IsXashFWGS ())
649
- {
650
- return EngFuncs::DoubleTime ();
651
- }
652
-
653
- #if defined _WIN32
654
- static LARGE_INTEGER g_PerformanceFrequency;
655
- static LARGE_INTEGER g_ClockStart;
656
- LARGE_INTEGER CurrentTime;
657
-
658
- if ( !g_PerformanceFrequency.QuadPart )
659
- {
660
- QueryPerformanceFrequency ( &g_PerformanceFrequency );
661
- QueryPerformanceCounter ( &g_ClockStart );
662
- }
663
-
664
- QueryPerformanceCounter ( &CurrentTime );
665
- return (double )( CurrentTime.QuadPart - g_ClockStart.QuadPart ) / (double )( g_PerformanceFrequency.QuadPart );
666
- #elif defined __DOS__
667
- // fallback when no time api
668
- return gpGlobals->time + 0.01 ;
669
- #elif defined __APPLE__
670
- struct timeval tv;
671
- gettimeofday (&tv, NULL );
672
- return (double ) tv.tv_sec + (double ) tv.tv_usec /1000000.0 ;
673
- #else
674
- struct timespec ts;
675
- clock_gettime (CLOCK_MONOTONIC, &ts);
676
- return (double ) ts.tv_sec + (double ) ts.tv_nsec /1000000000.0 ;
677
- #endif
678
- }
0 commit comments