1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-06-25 22:53:22 +00:00

Various cherry picks from world thread safety

- Ensure monitor draw lists are not reused after deleting them.
 - Make terminal methods synchronized, avoding NPEs and IOOBEs when
   resizing.
This commit is contained in:
SquidDev 2018-02-22 21:20:08 +00:00
parent 9be61abd6b
commit 244907a39a
2 changed files with 14 additions and 13 deletions

View File

@ -56,7 +56,7 @@ public Terminal( int width, int height )
m_palette = new Palette();
}
public void reset()
public synchronized void reset()
{
m_cursorColour = 0;
m_cursorBackgroundColour = 15;
@ -76,7 +76,7 @@ public int getHeight() {
return m_height;
}
public void resize( int width, int height )
public synchronized void resize( int width, int height )
{
if( width == m_width && height == m_height )
{
@ -189,7 +189,7 @@ public Palette getPalette()
return m_palette;
}
public void blit( String text, String textColour, String backgroundColour )
public synchronized void blit( String text, String textColour, String backgroundColour )
{
int x = m_cursorX;
int y = m_cursorY;
@ -202,7 +202,7 @@ public void blit( String text, String textColour, String backgroundColour )
}
}
public void write( String text )
public synchronized void write( String text )
{
int x = m_cursorX;
int y = m_cursorY;
@ -215,7 +215,7 @@ public void write( String text )
}
}
public void scroll( int yDiff )
public synchronized void scroll( int yDiff )
{
if( yDiff != 0 )
{
@ -245,7 +245,7 @@ public void scroll( int yDiff )
}
}
public void clear()
public synchronized void clear()
{
for( int y = 0; y < m_height; ++y )
{
@ -256,7 +256,7 @@ public void clear()
m_changed = true;
}
public void clearLine()
public synchronized void clearLine()
{
int y = m_cursorY;
if( y >= 0 && y < m_height )
@ -268,7 +268,7 @@ public void clearLine()
}
}
public TextBuffer getLine( int y )
public synchronized TextBuffer getLine( int y )
{
if( y >= 0 && y < m_height )
{
@ -277,7 +277,7 @@ public TextBuffer getLine( int y )
return null;
}
public void setLine( int y, String text, String textColour, String backgroundColour )
public synchronized void setLine( int y, String text, String textColour, String backgroundColour )
{
m_text[y].write( text );
m_textColour[y].write( textColour );
@ -285,7 +285,7 @@ public void setLine( int y, String text, String textColour, String backgroundCol
m_changed = true;
}
public TextBuffer getTextColourLine( int y )
public synchronized TextBuffer getTextColourLine( int y )
{
if( y>=0 && y<m_height )
{
@ -294,7 +294,7 @@ public TextBuffer getTextColourLine( int y )
return null;
}
public TextBuffer getBackgroundColourLine( int y )
public synchronized TextBuffer getBackgroundColourLine( int y )
{
if( y>=0 && y<m_height )
{
@ -318,7 +318,7 @@ public void clearChanged()
m_changed = false;
}
public NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound )
public synchronized NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound )
{
nbttagcompound.setInteger( "term_cursorX", m_cursorX );
nbttagcompound.setInteger( "term_cursorY", m_cursorY );
@ -338,7 +338,7 @@ public NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound )
return nbttagcompound;
}
public void readFromNBT( NBTTagCompound nbttagcompound )
public synchronized void readFromNBT( NBTTagCompound nbttagcompound )
{
m_cursorX = nbttagcompound.getInteger( "term_cursorX" );
m_cursorY = nbttagcompound.getInteger( "term_cursorY" );

View File

@ -29,6 +29,7 @@ public void destroy()
if( renderDisplayList != -1 )
{
ComputerCraft.deleteDisplayLists( renderDisplayList, 3 );
renderDisplayList = -1;
}
}
}